akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll fac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
    string s,t;
    cin >> s >> t;
    ll l=s.size();
    vector<pair<char,ll>> ma,mb;
    vl sa(l),ta(l);
    ll count=0;
    rep(i,l){
        bool hoge=true;
        rep(j,ma.size()){
            if(s[i]==ma[j].fi){
                sa[i]=ma[j].se;
                hoge=false;
            }
        }
        if(hoge){
            ma.pb(mp(s[i],count));
            sa[i]=count;
            count++;
        }
    }
    count=0;
    rep(i,l){
        bool hoge=true;
        rep(j,mb.size()){
            if(t[i]==mb[j].fi){
                ta[i]=mb[j].se;
                hoge=false;
            }
        }
        if(hoge){
            mb.pb(mp(t[i],count));
            ta[i]=count;
            count++;
        }
    }
    rep(i,l){
        if(ta[i]!=sa[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

using namespace std;

const int N=1e6+3;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9;

int n,m,a[N],k,q,u,v,x,y,tc,c,l,r,ans,p,cnt,root[N],sz[N];

char s[N];

bool ok[N];

set<int> nxt[26];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		ans+=max(0,a[i]-a[i-1]);
	printf("%d\n",ans);

	
}



Measured memory_bytes: 2304
#include <stdio.h>
int main(void)
{
	int i,j,n,x[4][13],num,typ;
	char tmp;
	scanf("%d",&n);
	for(i=0;i<4;i++){
		for(j=0;j<13;j++)
			x[i][j]=0;
	}
	for(i=0;i<n;i++){
		scanf(" %c %d",&tmp,&num);
		if(tmp=='S') typ=0;
		else if(tmp=='H') typ=1;
		else if(tmp=='C') typ=2;
		else if(tmp=='D') typ=3;
		j=num-1;
		x[typ][j]=1;
	}
	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			if(x[i][j]==0){
				if(i==0) tmp='S';
				else if(i==1) tmp='H';
				else if(i==2) tmp='C';
				else if(i==3) tmp='D';
				printf("%c %d\n",tmp,j+1);
			}
		}
	}
	return 0;
}

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

int main() {
	string s;
	cin >> s;
	int k = 0;
	if(s == "SUN")
	{
		k = 7;
	}
	else if(s == "MON")
	{
		k = 6;
	}
	else if(s == "TUE")
	{
		k = 5;
	}
	else if(s == "WED")
	{
		k = 4;
	}
	else if(s == "THU")
	{
		k = 3;
	}
	else if(s == "FRI")
	{
		k = 2;
	}
	else if(s == "SAT")
	{
		k = 1;
	}
	else
	{
		k = 0;
	}
    cout << k << endl;
	//SUN,MON,TUE,WED,THU,FRI,SAT
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
)

func run() int {
	var s string
	fmt.Scanf("%s\n", &s)

	var count int
	for i := 0; i < (len(s) / 2); i++ {
		if s[i] != s[len(s)-(i+1)] {
			count++
		}
	}

	fmt.Println(count)

	return 0
}

func main() {
	os.Exit(run())
}


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

int n,N;

int main()
{
	cin>>N;

	for(int n=1;n<=N;n++)
	{
		int ans=0;
		for(int x=1;x*x<=n;x++)
			for(int y=1;x*x+y*y+x*y<=n;y++)
				for(int z=1;x*x+y*y+z*z+x*y+y*z+z*x<=n;z++)
					if(x*x+y*y+z*z+x*y+y*z+z*x==n) ans++;
		cout<<ans<<"\n";
	}
}

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

int main() {
    int h, w;
  	cin >> h >> w;
  	vector<string> s(h);
  	rep(i, h){
    	cin >> s.at(i);
    }
  	rep(i, h+2){
    	if(i == 0 || i == h+1){
        	rep(j, w+2){
            	cout << "#";
            }
        }else{
        	cout << "#" << s[i-1] << "#";
        }
      	cout << endl;
    }
    return 0;
}

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

using namespace std;

#define REP(var, n)  for (int var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<int>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

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

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x << " "; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


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

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

auto solve() {
    int N, K;
    cin >> N >> K;
    vi a(N);
    for (auto &&e:a) cin >> e;

    const int MOD = 1e9 + 7;

    vector<vll> dp = vector<vll>(N + 1, vll(K + 1, 0));
    dp[0][0] = 1;

    REP(i, N) {
        ll sum = 0;
        REP(j, a[i] + 1) {
            sum += dp[i][j];
            sum %= MOD;
            dp[i + 1][j] += sum;
        }

        FOR(j, a[i] + 1, K + 1) {
            sum += dp[i][j];
            sum -= dp[i][j - a[i] - 1];
            sum = (sum + MOD) % MOD;
            dp[i + 1][j] += sum;
        }
    }

    return dp[N][K];
}


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

//    cout << (solve() ? "First" : "Second") << endl;
//    cout << (solve() ? "YES" : "NO") << endl;
    cout << solve() << endl;
//    solve();

    return 0;
}


Measured memory_bytes: 80256
import sys


def main():
    n = sys.stdin.readline().strip()
    p_s = sys.stdin.readline().strip()
    p = [int(s) for s in p_s.split()]
    ans = 0
    for i in range(len(p)-2):
        sorted_three = sorted(p[i:i+3])
        if sorted_three[1] == p[i+1] and sorted_three[0] < p[i+1]:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
N = int(input())
evenFlg = False
flg = False
lastIndex = int((N - (N % 2))/2)
if N % 2 == 0: evenFlg = True
ary = [2 for i in range(lastIndex)]
l = list(map(int, input().split()))
# for i in range(lastIndex):
#   ary.append(2)

if not evenFlg: ary.insert(0, 1)

for r in range(N):
    if evenFlg:
        l[r] = (l[r] - 1) / 2
    else:
        l[r] /= 2
    l[r] = int(l[r])
    ary[l[r]] -= 1
for k in range(lastIndex):
    if ary[k] != 0:
        flg = True
        break
ans = 0 if flg else (2**lastIndex) % (10**9 + 7)

print(ans)


Measured memory_bytes: 14768
#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++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
map<pair<int,int>,ll> mpi;
vector<int> to[100010];
vector<ll> dis(100010,inf);
void bfs(int i,int p){
    //if(p>=0)  dis[i] = min( dis[p] + mpi[{p,i}], dis[i] );
    //cout << i << " "<< p<< " " << dis[i] << " " <<  endl;
    for(auto u : to[i]){
        if(u==p) continue;
        dis[u] = dis[i] + mpi[{u,i}];
        //cout << dis[i] << " " << mpi[{u,i}] << " " << dis[u] << endl;
        bfs(u,i);
    }
}
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    rep(i,n-1){
        int a,b;
        ll c;
        cin >> a >> b >> c;
        a--;b--;
        mpi[{a,b}] = c;
        mpi[{b,a}] = c;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    int q,k;
    cin >> q >> k;
    k--;
    dis[k] = 0;
    bfs(k,-1);
    //for(auto )
    rep(i,q){
        int x,y;
        cin >> x >> y;
        x--;y--;
        cout << dis[x] + dis[y] << endl;
        //cout << dis[x] << endl << dis[y] << endl;
    }
    return 0;
}

Measured memory_bytes: 33024
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
bool b00l[123123];
signed main() {
	int n; string ans = "";
	int a = 0, b = 0, c;
	cin >> n;
	for1(i, n) {
		cin >> c;
		if (a < c) {
			for1(j, c - a)ans += '(';
			ans += ')';
			a = c;
		}
		else {
			bool b1 = 1;
			for (int j = c + 1; j <= a; j++)if (!b00l[j])b1 = 0;
			if (b1) { ans += ')'; }
			else {
				cout << ":(\n";
				return 0;
			}
		}
		b = c;
		b00l[c] = 1;
	}
	cout << ans << endl;
}


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

using namespace std;

#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()

const int MX = (int)1e5 + 10;
const int mod = (int)1e9 + 7;

int main(){

    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(0);

    double a, b, x;
    cin >> a >> b >> x;

    const double PI = acos(-1);
    double l = 0, r = 90;
    int it = 10000;
    while(it--){
        double md = (l + r) / 2;

        double angle = PI * md / 180.0;
        double ratio = tan(angle);
        double heightRem = a * ratio;

        if(heightRem >= b){
            double angle = 90 - md;
            double ratio = tan(angle * PI / 180.0);
            double org_base = b * ratio;
            double otherArea = 0.5 * org_base * b;
            if(otherArea * a >= x) l = md;
            else r = md;
            continue;
        }

        double areaExtra = 0.5 * a * heightRem;
        double ExtraVol = areaExtra * a;
        double rem = a * a * b - ExtraVol;

        if(rem >= x) l = md;
        else r = md;
    }
    
    cout << fixed << setprecision(6) << (l + r) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
s = input()
TF = []

for i in range(len(s)//2):
    if s[i] == s[-i-1]:
        TF.append(True)
    else:
        TF.append(False)
for j in range((len(s)//2)//2):
    if s[j] == s[len(s)//2 - j - 1]:
        TF.append(True)
    else:
        TF.append(False)
if all(TF):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, a[200009], dat[200009];
long long cnt;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		int tmp = i - a[i];
		if (tmp >= 0 && i) {
			dat[tmp]++;
		}
	}
	for (int i = 0; i < n; i++) {
		int tmp = i + a[i];
		if (tmp > 1e5 + 1e5) continue;
		cnt += dat[tmp];
		if (i - a[i] >= 0)
			dat[i - a[i]]--;
	}
	cout << cnt << "\n";
	//system("pause");
	return 0;
}

Measured memory_bytes: 5200
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	long long x,y,p=1000000007;
	long long ans=0,ue=1,st=1;
	cin>>x>>y;
    if((x+y)%3==0&&2*x>=y&&2*y>=x){
        int k=min((2*x-y)/3,(2*y-x)/3);
        int n=(x+y)/3;
        for(int i=n;i>n-k;i--){
            ue*=i;
            ue%=p;
        }
        for(int j=1;j<=k;j++){
            st*=j;
            st%=p;
        }
        vector<long long>bp(40);
        bp[1]=st;
        for(int a=2;a<40;a++){
            bp[a]=(bp[a-1]*bp[a-1])%p;
        }
        long long b=p-2;
        int cnt=1;
        while(b){
            if(b%2){
                ue*=bp[cnt];
                ue%=p;
            }
            b/=2;
            cnt++;
        }
        ans=ue;
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
vector<int> edge[d5],num,res;
int cnt=0;
void dfs(int x,int p){
    for(auto it:edge[x]){
        if(res[it]!=-1||p==it)continue;
        dfs(it,x);
    }
    res[x]=num[cnt];
    cnt++;
    /* for(auto it:res)cout<<it<<' ';
    cout<<endl; */
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    num.resize(n);
    res.resize(n,-1);
    for(int i=0;i<n;i++)cin>>num[i];
    sort(All(num));
    int M=0,idx=-1;
    for(int i=0;i<n;i++){
        int k=edge[i].size();
        if(M<k){
            M=k;
            idx=i;
        }
    }
    res[idx]=num[n-1];
    dfs(idx,idx);
    int ans=0;
    for(int i=0;i<n-1;i++)ans+=num[i];
    cout<<ans<<endl;
    for(int i=0;i<n;i++)cout<<res[i]<<' ';
    cout<<endl;
}

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

using namespace std;
using ll = long long;

void solve(){
	int a,b,t;
	cin >> a >> b >> t;
	cout << ((t/a)*b) << '\n';
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.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;
	float a[101],ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i]=1/a[i];
		ans+=a[i];
	}
	cout<<1/ans;
	return 0;
} 

Measured memory_bytes: 256
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> N;
  if (N/100 == 1) cout << 9;
  else cout << 1;
  if ((N/10-(N/100)*10)== 1) cout << 9;
  else cout << 1;
  if ((N-(N/100)*100-(N/10-(N/100)*10)*10) == 1) cout << 9;
  else cout << 1;


}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Long X = sc.nextLong();
        Long Y = sc.nextLong();
        Long sum = X * 2;//A2
        if(sum > Y){
            System.out.println("1");
            System.exit(0);
        }
        int count = 2;
        while(true){
            sum = sum * 2;//A3～
            if(sum > Y){
                System.out.println(count);
                System.exit(0);
                /*
                if(count == 2){
                    System.out.println("2");
                    System.exit(0);
                }else{
                    System.out.println(count);
                    System.exit(0);
                }
                */
            }
            count++;
        }
    }
}

Measured memory_bytes: 21844
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 文字列の入力
		String[] s = sc.next().split("");
        int count = 0;
        for(String n : s) {
          if ("o".equals(n)) {
            count++;
          }
        }
      
		// 出力
		System.out.println(700 + count * 100);
	}
}


Measured memory_bytes: 21844
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;

inline int read(){
	re int ans = 0;re bool f = 1;re char ch = getchar();
	while(ch<'0'||ch>'9'){if (ch=='-')f = 0;ch = getchar();}
	while(ch>='0'&&ch<='9'){
		ans = (ans<<3)+(ans<<1)+(ch^48);
		ch = getchar();
	}
	return f?ans:~(ans-1);
}
char s[4096];
char need[4096][4096];
int e[4096],f[4096],g[4096];
map<int,char>p;
signed main(void){
	int n = read();
	int ans = 0,a = 0,b = 0,c = 0;
	scanf("%s",s);
	p[(int)('R'+'G')]='B';
	p[(int)('B'+'G')]='R';
	p[(int)('R'+'B')]='G';
	for(re int i=0;i<n;++i){
		switch(s[i]){
			case 'R':++a;e[i] = a;f[i] = b;g[i] = c;break;
			case 'G':++b;e[i] = a;f[i] = b;g[i] = c;break;
			case 'B':++c;e[i] = a;f[i] = b;g[i] = c;break;
		}
		for(re int j=i+1;j<n;++j){
			if(s[i]==s[j])continue;
			need[i][j] = p[(int)(s[i]+s[j])];
		}
	}
	for(re int i=0;i<n;++i){
		for(re int j=i+1;j<n;++j){
			int aa = 0,bb = 0,cc = 0;
			if(s[2*j-i]==need[i][j])aa--,bb--,cc--;
			aa+=a-e[j];bb+=b-f[j];cc+=c-g[j];
			aa=max(aa,0LL),bb=max(bb,0LL),cc=max(cc,0LL);
			switch(need[i][j]){
				case 'R':ans+=aa;break;
				case 'G':ans+=bb;break;
				case 'B':ans+=cc;break;
			}
			
		}
	}
	/*
	for(re int i=0;i<n-3;++i){
		for(re int j=i+1;j<n;++j){
			for(re int k=j+1;k<n;++k){
				if(s[i]==s[j]||s[j]==s[k]||s[i]==s[k]||j-i==k-j)continue;
				ans++;
			}
		}
	}*/
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 19700
def main():
    H, W = map(int, input().split())
    cell = [list(input()) for _ in range(H)]
    rlist = list()
    clist = list()
    for i in range(H):
        if cell[i].count(".") == W:
            rlist.append(i)
    for j in range(W):
        c = 0
        for i in range(H):
            if cell[i][j] == ".":
                c += 1
            if c == H:
                clist.append(j)
    for i in range(H):
        if i in rlist:
            pass
        else:
            for j in range(W):
                if j in clist:
                    pass
                else:
                    print(cell[i][j], end="")
            print()
main()

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
int A, B, C,K;
	cin >> A >> B >> C >> K;
	ll ans = 0;
	if (A>=K) {
		ce(K)
		return 0;
	}
	ans = A;
	if (A+B>=K) {
		ce(ans);
		return 0;
	}
	ce(ans-(K-A-B))
    return 0;
}



Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;
typedef pair<int,int> P;
int INF=1000;

int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
int H, W;
char S[25][25];
int path[25][25];
P pos;

int bfs(int x, int y){
	rep(i,H+2){
		rep(j,W+2) path[i][j]=INF;
	}
	path[x][y]=0;
	queue<P> q;
	q.push(make_pair(x,y));
	pos=make_pair(x,y);
	while(!q.empty()){
		pos=q.front();
		q.pop();
		rep(i,4){
			int nx=pos.first+dx[i], ny=pos.second+dy[i];
			if(S[nx][ny]=='.'&&path[nx][ny]==INF){
				q.push(make_pair(nx,ny));
				path[nx][ny]=path[pos.first][pos.second]+1;
			}
		}
	}
	int longest=0;
	rep(i,H+2){
		rep(j,W+2){
			if(S[i][j]=='.') longest=max(longest,path[i][j]);
		}
	}
	return longest;
}

int main(){
	cin >> H >> W;
	rep(i,H){
		rep(j,W) cin >> S[i+1][j+1];
	}
	rep(i,H+2) S[i][0]='#', S[i][W+1]='#';
	rep(j,W+2) S[0][j]='#', S[H+1][j]='#';
	int l[25][25];
	rep(i,H+2){
		rep(j,W+2){
			if(S[i][j]=='.') l[i][j]=bfs(i,j);
		}
	}
	int ans=0;
	rep(i,H+2){
		rep(j,W+2){
			if(S[i][j]=='.') ans=max(ans,l[i][j]);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n,c,k=map(int,input().split())
a=[int(input()) for i in range(n)]
a.sort()
ans=0
cnt=[0,a[0]]
for i in range(n):
  if cnt[0]==c or a[i]-cnt[1]>k:
    ans+=1
    cnt[0]=1
    cnt[1]=a[i]
  else:
    cnt[0]+=1
if cnt[0]>=1:
  ans+=1
print(ans)

Measured memory_bytes: 7496
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {
    // 入力
    ll N,A,B,C,D;
    string S;
    cin >> N >> A >> B >> C >> D >> S;
    string out = "Yes";
    rep(i,D-2){
        if(i>A-1&&S[i]=='#'&&S[i+1]=='#'){
            out = "No";
            break;
        }
    }
    if(out=="Yes"){
        if(C>D){
            out = "No";
            for(ll i=B-2;i<D-1;i++){
                if(S[i]=='.'&&S[i+1]=='.'&&S[i+2]=='.') out = "Yes";
            }
        }
    }
    cout << out << endl;
    return 0;
}


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

int main() {
  string s;
  cin >> s ;
  cout << ((s[0]==s[1]&&s[1]==s[2]) || (s[1]==s[2]&&s[2]==s[3]) ? "Yes":"No") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int a, b;
	scanf("%d %d", &a, &b);
	if (a > b) printf("a > b\n");
	if (a < b) printf("a < b\n");
	if (a == b) printf("a == b\n");
	return 0;
}
	

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll w,a,b;
cin>>w>>a>>b;
if(fabs(a-b)<=w){
    cout<<0<<endl;
}else if(a>b){
    cout<<a-(b+w)<<endl;
}else{
    cout<<b-(a+w)<<endl;
}
}










Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long int
map<int,int> mp;
int a[100005]={0};
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int cnt=0;
    ll ans=1;
    for(int i=n-1;i>=0;i--)
    {
        //cout<<a[i]
        mp[a[i]]++;
        if(mp[a[i]]==2)
        {
            ans*=a[i];
            cnt++;
            //cout<<a[i];
        }
        if(mp[a[i]]==4)
        {
            ans*=a[i];
            cnt++;
        }
        if(cnt==2)
            break;
    }
    if(cnt<2)
        cout<<"0";
    else
        cout<<ans;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 500005;

int a, res;

int main() {
scanf("%d", &a);
res = (a / 500) * 1000;
a %= 500;
res += (a / 5) * 5;
printf("%d\n", res);
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a;
	long long n,r,b;
	r=b=0;
	scanf("%d",&n);
	for(int i=0;i<=n;i++)
	{
		scanf("%c",&a);
		if(a=='R')
			r++;
		else if(a=='B')
			b++;
	}
	if(r>b)
		printf("Yes");
	else if(r<=b)
		printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

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

bool pri[300000];
void solvePrime(){
    rep(i,300000){
        pri[i]=is(i);
    }
}


int main(){
    solvePrime();
    
    int a;
    
    while(cin>>a){
        int c=0;
        if(a==0)break;
        for(int i=a+1;i<=a*2;i++){
            if(pri[i])c++;
        }
        cout<<c<<endl;
    }
    return 0;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  int answer = 1;
  for(int i = 0;i < N ;i++) {
    if(answer + K >= answer * 2) {
      answer = answer * 2;
    }
    else if(answer + K < answer * 2) {
      answer = answer + K;
    }
  }
  cout << answer << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)

int N,K;
string S;
int A[100010];

signed main(){
	cin>>N>>K>>S;
	int l=0,r=0;
	int now=0;
	int ans=0;
	if(S[0]=='0'){
		A[0]=1;
	}
	REP(i,N-1){
		if(S[i]=='1'&&S[i+1]=='0'){
			A[i+1]=1;
		}
		if(S[i]=='0'&&S[i+1]=='1'){
			A[i+1]=-1;
		}
	}
	if(A[0]==1){
		now=1;
	}
	while(l<=N-1){
		if(now<=K){
			ans=max(ans,r-l+1);
		}
		if(now<=K&&r<N-1){
			r++;
			if(A[r]==1){
				now++;
			}
		}
		else{
			l++;
			if(A[l]==-1){
				now--;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1280
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
using namespace std;

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

const int MAX_N = 1000000, Inf = 1<<28;
int dp[2][MAX_N];

int main() {
  rep(i,MAX_N) rep(j,2) dp[j][i] = Inf;
  dp[0][0] = dp[1][0] = 0;

  for (int i = 1; i*(i+1)*(i+2)/6 < MAX_N; ++i) {
    const int v = i*(i+1)*(i+2)/6;
    for (int j = 1; j < MAX_N; ++j) {
      if (j-v < 0) continue;
      dp[0][j] = min(dp[0][j], dp[0][j-v]+1);
      if (v%2)
        dp[1][j] = min(dp[1][j], dp[1][j-v]+1);
    }
  }

  int in;
  while (scanf("%d",&in),in) {
    printf("%d %d\n",dp[0][in], dp[1][in]);
  }
  return 0;
}

Measured memory_bytes: 8560
#include <iostream>

using namespace std;

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

  int ans = n;
  if (n == 100) {
    ans = 101;
  }

  for (int i = 0; i < d; i++) {
    ans *= 100;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class BCountingRoads {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n, m;
        in >> n >> m;
        vi counter(n);
        FOR(i, 0, m) {
            int u, v;
            in >> u >> v;
            counter[u - 1]++;
            counter[v - 1]++;
        }
        trav(x, counter) {
            out << x << '\n';
        }
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    BCountingRoads solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3628
def main():
  n,m = list(map(int,input().split()))
  dic={}
  for i in range(1,n+1):
    dic[i]=0
  for _ in range(m):
    b, c = map(int, input().split())
    dic[b]+=1
    dic[c]+=1
  for i in range(1,n+1):
    print(dic[i])

main()

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

int main() {
  int W, H, N;
  cin >> W >> H >> N;

  int X = 0, Y = 0;

  for (int i = 0; i < N; i++) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) X = max(X, x);
    if (a == 2) W = min(W, x);
    if (a == 3) Y = max(Y, y);
    if (a == 4) H = min(H, y);
  }

  cout << max(W - X, 0) * max(H - Y, 0) << "\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  string a, b, c;
  cin >> a >> b >> c;

  bool result = true;
  result &= a[a.size() - 1] == b[0];
  result &= b[b.size() - 1] == c[0];

  puts(result ? "YES" : "NO");
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

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

  if(str == "a" || str == "i" || str == "u" || str == "e" || str == "o")
    cout << "vowel" << endl;
  else cout << "consonant" << endl;
  return 0;
}

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

int main() {
    ll N; cin >> N;
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        ll m = N / i;
        ans += ((m * (m+1)) / 2) * i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int num,x=0;
	string str,sum,ans;
	char c;
	while(getline(cin,str)){
		for(int j=0;j<26;j++){
			sum="";
			for(int i=0;i<str.size();i++){
				if('a'<=str[i]&&str[i]<='y'){
					c=str[i];
					c+=1;
					sum+=c;
				}else if(str[i]=='z'){
					c=str[i];
					c-=25;
					sum+=c;
				}else{
					c=str[i];
					sum+=c;
				}
			}
			swap(str,sum);
			num=0;
			for(int l=0;l<str.size();l++){
				if(str[l]==' '||str[l]=='.'){
					ans="";
					for(int k=num;k<l;k++){
						c=str[k];
						ans+=c;
					}
					num=l+1;
					if(ans=="this"||ans=="that"){
						x=1;
						break;
					}else if(ans=="the"){
						x=1;
						break;
					}
				}
			}
			if(x==1){
				cout<<str<<endl;
				x=0;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2984
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

lo n,m,b[li],a[li],k,flag,t,dp[2005][2005];
lo cev;
string s;
vector<lo> v;

inline lo mul(lo x,lo y){
	return (x%mod)*(y%mod)%mod;
}

inline lo add(lo x,lo y){
	if(x+y>=mod)return x+y-mod;
	return x+y;
}

int main(void){
	scanf("%lld %lld",&n,&k);
	for(int i=0;i<2002;i++){
		dp[i][0]=1;
		for(int j=1;j<=i;j++){
			dp[i][j]=add(dp[i-1][j-1],dp[i-1][j]);
		}
	}
	for(int i=1;i<=k;i++){
		printf("%lld\n",mul(dp[k-1][i-1],dp[n-k+1][i]));
	}
	return 0;
}


Measured memory_bytes: 31616
import queue

k = int(input())

q = queue.Queue()

for i in range(9):
  q.put(i+1)
  
for i in range(k):
  ans = q.get()
  if ans%10 != 0:
    q.put(10*ans+ans%10-1)
  q.put(10*ans+ans%10)
  if ans%10 != 9:
    q.put(10*ans+ans%10+1)
    
print(ans)
  


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

int main() {
  int A, B;
  cin >> A >> B;
  int sum = 0;
  for(int i = A; i <= B; i++) {
    int a, b, c, d;
    a = i % 10;
    b = (i / 10) % 10;
    c = i / 10000;
    d = (i - c * 10000) / 1000;
    if(a == c && b == d) {
      sum++;
    }
    
  }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+1;

int main(){
int n,A[N],B[N],C[N],dp[N][4];

cin>>n;
for(int i=0;i<n;++i)
scanf("%d%d%d",&A[i],&B[i],&C[i]);

dp[0][1]=A[0];
dp[0][2]=B[0];
dp[0][3]=C[0];

for(int i=1;i<n;++i){
    dp[i][1]=A[i]+max(dp[i-1][2],dp[i-1][3]);
    dp[i][2]=B[i]+max(dp[i-1][1],dp[i-1][3]);
    dp[i][3]=C[i]+max(dp[i-1][1],dp[i-1][2]);
}
cout<<max(dp[n-1][1],max(dp[n-1][2],dp[n-1][3]));
return 0;    
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define FOR(i,a,b) for(register int i=a;i<=b;i++)
#define LL long long

using namespace std;

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

priority_queue <LL, vector<LL>,greater<int> > Q2;
priority_queue <LL> Q1;

LL k=0;
LL Ans=0;
//int sum1=0; int sum2=0;

void ADD(LL x){
	
	if(Q1.size()==0){
		Q1.push(x);
		return;
	}
	if(Q2.size()==0){
		if(x<Q1.top()){
			Q1.push(x);
			Q2.push(Q1.top());
			Q1.pop();
		}
		else
			Q2.push(x);
		Ans=Q2.top()-Q1.top();
		return;
	}
	
	int tot=Q1.size()+Q2.size();
	int lim=(tot+1+1)/2;
	if(Q1.top()>=x){
		//sum1+=x;
		Ans+=abs(Q1.top()-x);
		Q1.push(x);
	}
	else{
		//sum2+=x;
		Ans+=abs(Q1.top()-x);
		Q2.push(x);
	}
	while(Q1.size()>lim){
		Q2.push(Q1.top()); Q1.pop();
		Ans=Ans+(Q2.size()-Q1.size())*(Q2.top()-Q1.top());
	}
	while(Q1.size()<lim){
		int tri=Q2.top()-Q1.top();
		Q1.push(Q2.top()); Q2.pop();
		Ans=Ans+((Q1.size()-1)-(Q2.size()+1))*tri;
	}
}

int main(){
	
	int n=read();
	FOR(i,1,n){
		
		int mode=read();
		
		if(mode==1){
			ADD(read());
			k+=read();
			//cout<<" A "<<Ans<<endl;
			//cout<<" Q "<<Q1.top()<<endl;
		}
		else{
			cout<<Q1.top()<<" "<<Ans+k<<endl;
		}
		
	}
	
	return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
char s[100001];
int dp[100001]={};
int main()
{
    cin >> s;
    int z0,z1,o0,o1;
    z0=z1=o0=o1=0;
    for(int i=0;i<strlen(s);i++)
    {
    	if(s[i]=='0'&&i%2==0)
    	z0++;
    	else if(s[i]=='0'&&i%2==1)
    	z1++;
    	else if(s[i]=='1'&&i%2==0)
    	o0++;
    	else o1++;
	}
	int op=min(z0+o1,z1+o0);
	cout << op << endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
int i,j,n=0,flag,k,p;
char s[111],t[111];
for(i=0;i<111;i++){
s[i]='\0';
t[i]='\0';
}
scanf("%s%*c%s",s,t);
while(s[n]!='\0')
n++;
for(i=0;i<n;i++){
flag=1;
k=i;
p=0;
for(j=0;j<n;j++){
if(t[p]!=s[k]){
flag=0;
}
if(k==n-1)
k=-1;
k++;
p++;
}
if(flag==1){
printf("Yes\n");
return 0;
}
}
printf("No\n");
return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

string s, t;

vector<int> pos[256];

void solve()
{
	cin >> s >> t;

	for(int i = 0; i < len(s); ++i)
		pos[s[i]].push_back(i);

	ll answ = 0;
	int cur = NIL;

	for(auto& ch: t)
	{
		const auto& inds = pos[ch];

		if(inds.empty())
		{
			cout << NIL << endl;
			return;
		}

		auto iter = upper_bound(inds.begin(), inds.end(), cur);

		if(iter == inds.end())
			iter = inds.begin();

		int nxt = *iter;

		answ += (nxt > cur ? nxt - cur : nxt - cur + len(s));
		cur = nxt;
	}

	cout << answ << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
vector<l_l> v;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    if((N - 1) * (N - 2) / 2 < K) {
        cout << -1 << endl;
        return 0;
    }
    for(int i = 2; i <= N; i++) v.emplace_back(1, i);
    int rest = (N - 1) * (N - 2) / 2 - K;
    for(int i = 2; i <= N; i++) {
        for(int j = i + 1; j <= N; j++) {
            if(rest == 0) break;
            rest--;
            v.emplace_back(i, j);
        }
    }
    cout << v.size() << endl;
    for(int i = 0; i < v.size(); i++) {
        cout << v[i].first << " " << v[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 512
package main

import (
	"fmt"
)

func main() {
	N := 0
	M := 0
	fmt.Scan(&N, &M)
	// fmt.Printf("N, %v\n", N)
	// fmt.Printf("M, %v\n", M)

	Lmin := 0
	Rmax := 100001

	for i := 0; i < M; i++ {
		L, R := 0, 0
		fmt.Scan(&L, &R)
		// fmt.Printf("L, %v\n", L)
		// fmt.Printf("R, %v\n", R)
		if L > Lmin {
			Lmin = L
		}

		if R < Rmax {
			Rmax = R
		}
	}

	//fmt.Printf("Lmin, %v\n", Lmin)
	//fmt.Printf("Rmax, %v\n", Rmax)

	if N < Rmax {
		t := N - Lmin
		fmt.Printf("t1, %v\n", t)
		//if t > 100000 {
		//	// fmt.Printf("total1, %v\n", 10000)
		//	fmt.Println(100000)
		//} else {
		//	fmt.Println((N - Lmin) + 1)
		//	// fmt.Printf("total1, %v\n", (N - Lmin) + 1)
		//}
		if t < 0 {
			fmt.Println(0)
		} else {
			fmt.Println((N - Lmin) + 1)
		}


	} else {
		t := Rmax - Lmin
		//fmt.Printf("t2, %v\n", t)
		//if t > 100000 {
		//	// fmt.Printf("total2_1, %v\n", 100000)
		//	fmt.Println(100000)
		//} else {
		//	// fmt.Printf("total2_2, %v\n", (Rmax - Lmin) + 1)
		//	fmt.Println((Rmax - Lmin) + 1)
		//}
		if t < 0 {
			fmt.Println(0)
		} else {
			fmt.Println((Rmax - Lmin) + 1)
		}

	}
}


Measured memory_bytes: 5504