akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main()
{
    char a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a==b&&c==d&&a!=c&&a!=d)
    {
        cout<<"Yes";
    }
    else if(a==d&&b==c&&a!=b&&a!=c)
    {
        cout<<"Yes";
    }
    else if(a==c&&b==d&&a!=b&&a!=d)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }



    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>

using namespace std;

int main(){

	int height,width,tmp;
	scanf("%d %d",&height,&width);

	int** table = new int*[height+1];
	table[0] = new int[width+1];
	for(int i=0; i < width+1; i++)table[0][i] = 0;

	int max_r = 0;

	for(int i=1; i <= height; i++){
		table[i] = new int[width+1];
		table[i][0] = 0;
		for(int k=1; k <= width; k++){
			scanf("%d",&tmp);
			table[i][k] = 1-tmp;
			if(tmp != 1){
				table[i][k] = min(table[i-1][k-1],min(table[i][k-1],table[i-1][k]))+1;
				max_r = max(max_r,table[i][k]);

			}

		}
	}

	printf("%d\n",max_r*max_r);

    return 0;
}

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

int main(){
    string S;
    char C[4]={'A','C','G','T'};
    int S_len,i,j,count=0,max=0;
    cin >> S;
    S_len = S.length();
    for(i=0;i<S_len;i++){
        for(j=0;j<4;j++){
            if(S[i]==C[j]){
                count++;
                break;
            }
        }
        if(j==4){
            if(count>max){
                max = count;
            }
            count = 0;
        }
    }
    if(count>max){
        max = count;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s,t;
int a,b;
string u;
int main()
{
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if(s==u) a--;
    if(t==u) b--;
    cout<<a<<" "<<b;
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}
 
int n, m, k;
map<int, int > p, cnt;

int get (int x) {
	if(p.count(x)) return p[x] = get(p[x]);
	return x;
}

int main () {
	SpeedForce;
	setIO();
	cin >> n;
	for (int i = 1, a; i <= n; ++i) {
		cin >> a;
		cnt[a]++;
	}

	ll ans = 0;
	for (auto it : cnt) ans += it.first * (ll)it.second;

	cin >> m;
	while(m--) {
		int b, c;
		cin >> b >> c;
		if(cnt.count(b)) {
			ans -= cnt[b] * (ll)b;
			ans += cnt[b] * (ll)c;
			cnt[c] += cnt[b];
			cnt[b] = 0;
		}
		cout << ans << '\n';
	}

	return Accepted;
}

// B...a

Measured memory_bytes: 7476
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> void re(T& x) { cin >> x; }
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
template<class H, class... T> void re(H& h, T&... t) { re(h); re(t...); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "/home/o_o/MyCodes/pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  


void solve(){
	int a ; re(a) ;
	cout << (a*a*a) + (a*a) + a << endl;
}


signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

int main() {
  int h, w, n, i, a = 0, b = 0;
  cin >> n >> h >> w;
  for(i = 0;i < n;i++){
    if(i + h <= n) a+=1;
  }
  for(i = 0;i < n;i++){
    if(i + w <= n) b+=1;
  }
  cout << a * b <<endl;
}

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



int main() {
	char a, b, c;
	int cun=0;
	cin >> a >> b >> c;
	if (a == '1')cun++;
	if (b == '1')cun++;
	if (c == '1')cun++;
	cout << cun << endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1<<30;

int main(){
  int n;cin>>n;
  vector<int> a(n), b(n);
  for(auto &e: a)cin>>e;
  for(auto &e: b)cin>>e;
  int ans=-INF;
  for(int i=0;i<n;i++){
    int count=0;
    for(int j=0;j<=i;j++){
      count += a[j];
    }
    for(int j=i;j<n;j++){
      count += b[j];
    }
    ans = max(ans, count);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
import math
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    ans = 0
    for i in range(1,N+1):
        n = N//i
        ans += n*(n+1)*i//2
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9116
import heapq
def f(str):
    return -int(str)

N, M = map(int, input().split())
A = list(map(f, input().split()))
heapq.heapify(A)

while M > 0:
    heapq.heappush(A, -(-heapq.heappop(A) // 2))
    M -= 1

print(-sum(A))


Measured memory_bytes: 14180
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC114A
{
    class Program
    {
        static void Main(string[] args)
        {
            int X;           
            
            var word = Console.ReadLine().Split(' ');  
            X = int.Parse(word[0]);
            if (X == 3 || X == 5 || X == 7) { Console.WriteLine("YES"); }
            else { Console.WriteLine("NO") ;}            
            
            Console.ReadKey();
        }
    }
}

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

int main() {
  int A, B;
  cin >> A >> B;
  
  int ans= 0;
  for(int i=A; i<B+1; i++){
    int i_1= i/10000   ;
    int i_2= i/1000 %10;
    int i_4= i/10   %10;
    int i_5= i      %10;
    if( i_1==i_5 && i_2==i_4 ) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
N,M=list(map(int,input().split()))
L=[]
R=[]
for i in range(M):
	l,r=list(map(int,input().split()))
	L.append(l)
	R.append(r)


Lmax=1
Rmin=N
for i in range(M):
	if L[i]>Lmax: Lmax=L[i]
	if R[i]<Rmin: Rmin=R[i]

if Lmax>Rmin: print(0)
else: print(Rmin-Lmax+1)

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

#define int long long
const int N = 1e5+5, LOGN = 20, INF = 1e18+9;
int n, q, u, v, dist;
int a[N], jump[LOGN][N];

void init()
{
    for (int i = 1; i <= LOGN; i++)
        for (int j = 1; j <= n; j++)
            jump[i][j] = jump[i-1][jump[i-1][j]];
}

int solve(int u, int v)
{
    int ans = 0;
    for (int j = LOGN; j >= 0; j--)
    {
        if (jump[j][u] < v)
        {
        u = jump[j][u];
        ans += (1<<j);
        }
    }
    return ans+1;
}

signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    cin >> dist;
    for (int i = 1; i <= n; i++)
    {
        int l = i;
        for(int j = 20; j >= 0; j--)
        {
            int r = l + (1<<j);
            if (r > n) continue;
            else
            {
                if (a[r] - a[i] <= dist) l += (1<<j);
            }
        }
        jump[0][i] = l;
    }
    init();
//    for (int i = 1; i <= n; i++)
//        cout << i << ' ' << jump[0][i] << ' ' << jump[1][i] << ' ' << jump[2][i] << endl;
    cin >> q;
    while(q--)
    {
        cin >> u >> v;
        if (v < u)
            swap(u,v);
//        solve(u,v);
        cout << solve(u,v) << endl;
    }
}
/*
9
1 3 6 13 15 18 19 29 31
10
6
3 4
3 5
3 6
3 7
3 8
3 9
*/
/*
9
1 3 6 13 15 18 19 29 31
10
1
1 2
*/


Measured memory_bytes: 17280
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(long long int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1LL << 60);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    fill((T*)array, (T*)(array + N), val);
}
int main() {
    ll n, k; cin >> n >> k; vector<int> a(n),c(n,0);
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }
    vector<bool> b(n, false); int now = 0, cnt = 0; ll h,seppen;
    for (;;) {
        now = a[now]; cnt++;
        if (b[now]) {
            cnt -= c[now];
            seppen = c[now];
            break;
        }b[now] = true;
        c[now] = cnt;
    }
    if (seppen >= k) {
        h = k;
    }
    else {
        h = (k - seppen) % cnt + seppen;
    }now = 0;
    rep(i, h) {
        now = a[now];
    }cout << now + 1 << endl;
}

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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  int l[N];
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }

  sort(l, l + N);

  int sum = 0;
  for (int i = 0; i < K; i++) {
    sum += l[N - i - 1];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=1;i<=N;i++)

signed main(){
  int X,N=1;
  cin>>X;
  rep(i,X){
    N*=i;
    if(N>1000000000)N%=1000000000+7;
  }
  cout<<N<<endl;
  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n;
    cin>>n;
    string str;
    string str1;
    cin>>str;
    cin>>str1;
    for(i=0;i<n;i++)
    {

        cout<<str[i]<<str1[i];
    }
  return 0;
}


Measured memory_bytes: 3592
///In the name of Almighty Allah(swt).

#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n,i,a=0,w=0,t=0,r=0;
    cin>>n;
    string s[n];
    for(i=0; i<n; i++)
    {
        cin>>s[i];
    }
    for(i=0; i<n; i++)
    {
        if(s[i] == "AC")
            a++;
        else if(s[i] == "TLE")
            t++;
        else if(s[i] == "WA")
            w++;
        else if(s[i] == "RE")
            r++;
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<w<<endl;
    cout<<"TLE x "<<t<<endl;
    cout<<"RE x "<<r<<endl;



    return 0;
}


Measured memory_bytes: 6760
#include<cstdio>
#include<algorithm>
using namespace std;
int n, a, ans;
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i){
		scanf("%d", &a);
		ans = __gcd(ans, a);
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
from math import sqrt, floor
from collections import deque
from functools import reduce
from operator import mul


def divide(p):
    global a, lcm, limit

    c, d, f = a.copy(), set(), False
    while True:
        b = set(i for i in c if not (i % p))
        d |= c - b
        if not b:
            a = d
            break
        lcm.append(p)
        c = set(i // p for i in b)
        f = True
    if f:
        limit = floor(sqrt(max(a)))


n, a = int(input()), set(map(int, input().split()))
p, lcm, limit = 3, deque(), floor(sqrt(max(a)))

divide(2)

while p <= limit:
    divide(p)
    p += 2

print(reduce(mul, lcm, 1) * reduce(mul, a, 1))

Measured memory_bytes: 8384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200003;
const ll INF=1LL<<60;

struct data{
    ll b;
    ll c;
    ll diff;
};

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int X,Y,Z;cin>>X>>Y>>Z;
    int N=X+Y+Z;
    vector<ll> A(N),B(N),C(N);
    ll sum=0;
    for(int i=0;i<N;i++){
        cin>>A[i]>>B[i]>>C[i];
        sum+=A[i];
        B[i]-=A[i];
        C[i]-=A[i];
    }
    
    vector<data> D(N);
    for(int i=0;i<N;i++){
        D[i]={B[i],C[i],B[i]-C[i]};
    }
    
    sort(all(D),[](data a,data b){
        return a.diff>b.diff;
    });
    
    vector<ll> bsum(N+2),csum(N+2);
    
    priority_queue<ll,vector<ll>,greater<ll>> PQ;
    
    for(int i=0;i<Y;i++){
        bsum[i+1]=bsum[i]+D[i].b;
        PQ.push(D[i].b);
    }
    
    for(int i=Y;i<N;i++){
        bsum[i+1]=bsum[i]+D[i].b;
        PQ.push(D[i].b);
        bsum[i+1]-=PQ.top();
        PQ.pop();
    }
    
    while(!PQ.empty()) PQ.pop();
    
    for(int i=0;i<Z;i++){
        csum[N-i]=csum[N-i+1]+D[N-1-i].c;
        PQ.push(D[N-1-i].c);
    }
    
    for(int i=Z;i<N;i++){
        csum[N-i]=csum[N-i+1]+D[N-1-i].c;
        PQ.push(D[N-1-i].c);
        csum[N-i]-=PQ.top();
        PQ.pop();
    }
    
    ll maxi=-INF;
    
    for(int i=Y;N-i>=Z;i++){
        maxi=max(maxi,bsum[i]+csum[i+1]);
    }
    
    cout<<sum+maxi<<endl;
    
    /*for(int i=0;i<=N+1;i++){
        cout<<bsum[i]<<" "<<csum[i]<<endl;
    }*/
}




Measured memory_bytes: 7672
#include<bits/stdc++.h>
using namespace std;
const int N=605;
int n,m;
double dp[N],f[N];
vector<int>v[N];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int x,y;scanf("%d%d",&x,&y);
        v[x].push_back(y);
    }
    for(int i=n-1;i>=1;i--)
    {
        double sum=0;
        for(int j=0;j<v[i].size();j++)
            sum+=dp[v[i][j]];
        dp[i]=sum/v[i].size()+1;
    }
    double ans=dp[1];
    for(int i=n-1;i>=1;i--)
    {
        if(v[i].size()>1)
        {
            double sum=0,mx=0;
            for(int j=0;j<v[i].size();j++)
                sum+=dp[v[i][j]],mx=max(mx,dp[v[i][j]]);
            sum-=mx;
            f[i]=sum/(v[i].size()-1)+1;
            for(int j=i-1;j>=1;j--)
            {
                double sum=0;
                for(int k=0;k<v[j].size();k++)
                    sum+=f[v[j][k]];
                f[j]=sum/v[j].size()+1;
            }
            ans=min(ans,f[1]);
        }
        f[i]=dp[i];
    }
    printf("%f\n",ans);
}


Measured memory_bytes: 1408
#include <iostream>
#include <limits>
#include <vector>
template <typename T>
constexpr T INF() { return std::numeric_limits<T>::max() / 16; }
constexpr int MOD = 1000000007;
template <typename Monoid>
class SegTree
{
    static std::size_t SZ(const std::size_t n)
    {
        std::size_t ans = 1;
        for (; ans < n; ans <<= 1) {}
        return ans;
    }

public:
    using BaseMonoid = Monoid;
    using T = typename Monoid::T;
    SegTree(const std::size_t n) : size(n), half(SZ(n)), value(half << 1, Monoid::id()) {}
    template <typename InIt>
    SegTree(const InIt first, const InIt last) : size(distance(first, last)), half(SZ(size)), value(half << 1, Monoid::id())
    {
        std::copy(first, last, value.begin() + half);
        for (std::size_t i = half - 1; i >= 1; i--) { up(i); }
    }
    T get(const std::size_t a) const { return value[a + half]; }
    void set(std::size_t a, const T& val)
    {
        value[a += half] = val;
        while (a >>= 1) { up(a); }
    }
    T accumulate(std::size_t L, std::size_t R) const
    {
        T accl = Monoid::id(), accr = Monoid::id();
        for (L += half, R += half; L < R; L >>= 1, R >>= 1) {
            if (L & 1) { accl = acc(accl, value[L++]); }
            if (R & 1) { accr = acc(value[--R], accr); }
        }
        return acc(accl, accr);
    }
    std::vector<T> data() const { return std::vector<T>(value.begin() + half, value.begin() + half + size); }

private:
    void up(const std::size_t i) { value[i] = acc(value[i << 1], value[i << 1 | 1]); }
    const std::size_t size, half;
    std::vector<T> value;
    const Monoid acc{};
};
template <typename T>
std::ostream& operator<<(std::ostream& os, const SegTree<T>& seg)
{
    os << "[";
    for (const auto e : seg.data()) { os << e << ","; }
    return (os << "]\n");
}
struct Sum
{
    using T = int;
    T operator()(const T& a, const T& b) const { return (a + b) % MOD; }
    static constexpr T id() { return 0; }
};
int main()
{
    int N, K;
    std::cin >> N >> K;
    std::vector<int> a(N);
    for (int i = 0; i < N; i++) { std::cin >> a[i]; }
    SegTree<Sum> dp(K + 1);
    dp.set(0, 1);
    for (int i = 0; i < N; i++) {
        for (int j = K; j >= 0; j--) {
            const int l = std::max(0, j - a[i]), r = j + 1;
            dp.set(j, dp.accumulate(l, r));
        }
    }
    std::cout << dp.get(K) << std::endl;

    return 0;
}


Measured memory_bytes: 1280
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int n = nextInt();
		int k = nextInt();
		out.println(n-k+1);
	}
	@SuppressWarnings("unused")
	private int min(int a, int b) {
		return Math.min(a, b);
	}
	@SuppressWarnings("unused")
	private int nextInt() {
		return Integer.parseInt(next());
	}
	@SuppressWarnings("unused")
	private long nextLong() {
		return Long.parseLong(next());
	}
	private String next() {
		return sc.next();
	}
}


Measured memory_bytes: 22100
s=input()

num=0
if s[0]=='A':
  if 'C' in s[2:-1]:
    tmp=s[1:].replace('C','c',1)
    if tmp.islower():
      print('AC')
    else:
      print('WA')
  else:
    print('WA')
else:
  print('WA')

Measured memory_bytes: 3060
/* Isn't passion overrated?*/

#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    ll n;
    cin>>n;
    ll a = n%10;
    if(a == 2 || a == 4 || a == 5 || a == 7 || a == 9)
        cout<<"hon";
    else if(a == 3)
        cout<<"bon";
    else
        cout<<"pon";
    return 0;
}


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

#define MOD  998244353
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};

ll A, B, C, D;

ll dp[4000][4000];

ll dpf(ll a, ll b){
  if(a==A and b==B)dp[a][b]=1;
  else if(dp[a][b]<0){
    dp[a][b] = 0;
    ll s=0, t=0, u=0;
    if(b-1>=B)s = dpf(a, b-1);
    if(a-1>=A)t = dpf(a-1, b);
    if(a-1>=A and b-1>=B)u = dpf(a-1, b-1);
    dp[a][b] = mod(s*a+t*b-u*(a-1)*(b-1), MOD);
  }
  return dp[a][b];
}

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  cin >> A >> B >> C >> D;
  fill(dp[0], dp[4000], -1);
  cout << dpf(C,D);
  return 0;
}


Measured memory_bytes: 128824
program main
    implicit none
    integer n,i
    integer :: s(4)=(/0,0,0,0/)
    character(3) c
    read(*,*)n
    do i=1,n
        read(*,*)c
        if(c=="AC ")then
            s(1)=s(1)+1
        else if(c=="WA ")then
            s(2)=s(2)+1
        else if(c=="TLE") then
            s(3)=s(3)+1
        else 
            s(4)=s(4)+1
        endif
    enddo
    write(*,*)"AC x ",s(1)
    write(*,*)"WA x ",s(2)
    write(*,*)"TLE x ",s(3)
    write(*,*)"RE x ",s(4)

end program main

Measured memory_bytes: 2860
function main(input) {
  const tmp = input.trim().split('\n')
  const n = parseInt(tmp[0], 10)
  const tmp2 = tmp[1].split(' ')
  const s = tmp2[0]
  const t = tmp2[1]

  let answer = ''
  for (let i = 0; i < n; i++) {
    answer += s[i] + t[i]
  }
  console.log(answer)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 29552
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iostream>
#include <deque>
#include <math.h>
#include <cstdio>
#include <functional>
#include <set>
#include <iomanip>
#include <cctype>
#include <tuple>
typedef  long long ll;
using namespace std;

int main(void) {
	ll n, k;
	cin >> n >> k;
	ll a = n % k;
	ll ans = min(a, k -a);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<string.h>
#include<math.h>
#include<queue>
#include<cstring>
#include<new>
#include<cmath>
#include<sstream>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define sz size()
#define em empty()
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define sett(a,b) memset(a,b,sizeof(a))
#define copy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
bool pr[101];
int d[101],a[10101];
int main(){
	int n;
	cin>>n;
	fo(i,1,100) fo(j,2,i)if(i%j==0)pr[i]=1;
	fo(i,1,n+1){
	int x=i;
	fo(j,2,n+1)
	if(!pr[j])while(x%j==0){
		x/=j;
		d[j]++;
	}
	} 
	fo(i,1,1010) fo(j,1,n+1)if(d[j]>=i)a[i]++;
	cout<<a[74]+a[24]*(a[2]-1)+a[14]*(a[4]-1)+a[4]*(a[4]-1)*(a[2]-2)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int a; 
    scanf("%d", &a);
    
    if(a<1200)
    {
        printf("ABC");
    }
    
    else
    {
        printf("ARC");
    }
}


Measured memory_bytes: 3740
#include<set>
#include<map>
#include<ctime>
#include<queue>
#include<cmath>
#include<climits>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
    int f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
#define MAXN 200000
#define INF 0x3f3f3f3f
int chan1[30],chan2[30];
bool app[30];//1 s->t  2 t->s
char S[MAXN+5],T[MAXN+5];
int main(){
	scanf("%s %s",S+1,T+1);
	int len=strlen(S+1);
	for(int i=1;i<=len;i++){
		if(chan1[S[i]-'a']){
			if(chan1[S[i]-'a']==T[i]-'a')
				continue;
			else{
				puts("No");
				return 0;
			}
		}
		else
			chan1[S[i]-'a']=T[i]-'a';
		if(chan2[T[i]-'a']){
			if(chan2[T[i]-'a']==S[i]-'a')
				continue;
			else{
				puts("No");
				return 0;
			}
		}
		else
			chan2[T[i]-'a']=S[i]-'a';
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

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

int main() {
  int a,b;
  cin >> a >>b;

  if(a>=13){
    cout << b << endl;
  }
  else if(a>=6 && a<=12){
    cout << b/2 << endl;
  }
  else if(a<=5){
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int N = 3000;
bool sugar[N + 5], water[N + 5];
int main()
{
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	sugar[0] = water[0] = true;
	for (int i : {c, d})
		for (int j = i; j <= N; j++)
			sugar[j] |= sugar[j - i];
	for (int i : {a, b})
		for (int j = i; j <= N; j++)
			water[j] |= water[j - i];
	int s = 0, w = a;
	for (int i = 0; i <= N; i++)
		for (int j = 0; j <= N; j++)
			if (sugar[i] && water[j] && i + 100 * j <= f && e * j >= i && i * w > s * j)
			{
				s = i;
				w = j;
			}
	cout << s + 100 * w << ' ' << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
ll cnt = 0;

int main(){
   double n,k; cin >> n >> k;
   cout << fixed << setprecision(15);
   double a,b,ans=0;
   
   for(int i=1;i<=n;i++){
       int j=0;
      while(1){
          if(i*pow(2,j) >= k){
              b=j;
              break;
          }
          j++;
      }
    
        ans+= (1/(double)n)*( pow(0.5,b) );
    }
   cout << ans  << endl;
}

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

using namespace std;

int N;
double pw, vw[100010], pf[100010], vf[100010], th[100010];

double f(double x)
{
  double ret = pw*x;
  for(int i = 0; i < N; i++) {
    double v = vw[i]*x;
    if(v >= th[i]) continue;
    ret += pf[i] * (th[i] - v)/vf[i];
  }
  return ret;
}

double ternary_search()
{
  double l = 0.0, r = 1000.0;
  for(int i = 0; i < 200; i++) {
    double c = (r - l) / 3.0;
    double a = l + c, b = r - c;
    if(f(a) >= f(b)) l = a;
    else r = b;
  }
  return f(l);
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(cin >> N, N) {
    cin >> pw;
    for(int i = 0; i < N; i++) cin >> vw[i] >> pf[i] >> vf[i] >> th[i];
    cout << ternary_search() << endl;
  }
  
  return 0;
}

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

int main() {
  string s;
  cin >>s;
  vector<string>t(16);
  t[0]="KIHBR";
  t[1]="KIHBRA";
  t[2]="KIHBAR";
  t[3]="KIHBARA";
  t[4]="KIHABR";
  t[5]="KIHABRA";
  t[6]="KIHABAR";
  t[7]="KIHABARA";
  t[8]="AKIHBR";
  t[9]="AKIHBRA";
  t[10]="AKIHBAR";
  t[11]="AKIHBARA";
  t[12]="AKIHABR";
  t[13]="AKIHABRA";
  t[14]="AKIHABAR";
  t[15]="AKIHABARA";
  for(int i=0;i<16;i++){
    if(s==t[i]){
      cout<<"YES"<<endl;
      return 0;
    }
  }cout<<"NO"<<endl;
  return 0;
}

  

Measured memory_bytes: 3600
import copy
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
count=dict(Counter(a))
ans=0
dic={}
for j,k in count.items():
    ans=k*(k-1)/2
    dic[j]=ans
s=sum(dic.values())
for i in range(n):
    v=count[a[i]]
    if v==0:
        print(0)
    else:
        print(int(s-v+1))


Measured memory_bytes: 101704
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const LL MOD=1000000007ll;
const LL INF=2000000000ll;

long power(long a,long b){return b?power(a*a%MOD,b/2)*(b%2?a:1)%MOD:1;}
long comb(int N,int K)
{
	long x=1,y=1;
	for(int i=1;i<=K;i++)
	{
		x=x*(N-i+1)%MOD;
		y=y*i%MOD;
	}
	return x*power(y,MOD-2)%MOD;
}

long hcomb(int N, int K){
    return comb(N+K-1, N-1);
}

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

    int n,q;
    cin >> n;
    VI S(n);
    map<int,int> s;
    REP(i,n) {
        cin >> S[i];
        s[S[i]] = 1;
    }
    sort(ALL(S));
  	cin >> q;
    VI T(q);
    int cnt = 0;
    REP(i,q) {
        cin >> T[i];
        if (s[T[i]]) cnt++;
    }

    cout << cnt << endl;




}


Measured memory_bytes: 10412
N = int(input())
Red = sorted([tuple(map(int, input().split())) for _ in range(N)])
Blue = sorted([tuple(map(int, input().split())) for _ in range(N)])

ans = 0
for bx,by in Blue:
    C = [(y,x) for x,y in Red if x<bx and y<by] #候補
    if len(C) == 0:
        continue
    ans += 1
    C.sort(reverse=True)
    Red.remove((C[0][1],C[0][0]))
print(ans)

Measured memory_bytes: 9220
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void) {
	char mimori_suzuko[2048], *fukuenn_misato;
	if (fgets(mimori_suzuko, sizeof(mimori_suzuko), stdin) == NULL) return 1;
	if ((fukuenn_misato = strchr(mimori_suzuko, '\n')) != NULL) *fukuenn_misato = '\0';
	for (fukuenn_misato = mimori_suzuko; *fukuenn_misato != '\0'; fukuenn_misato++) {
		int katou_emiri = (unsigned char)*fukuenn_misato;
		if (islower(katou_emiri)) putchar(toupper(katou_emiri));
		else if (isupper(katou_emiri)) putchar(tolower(katou_emiri));
		else putchar(katou_emiri);
	}
	putchar('\n');
	return 0;
}



Measured memory_bytes: 2080
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
struct bt{
  int a,b,c,d;
  int e;
  struct bt* l;
  struct bt* r;
};
int f(int a[][4],string s,struct bt* p,int e){
  int i,j;
  if(s[0]=='('){
    p->l=(struct bt*)malloc(sizeof(struct bt));
    p->r=(struct bt*)malloc(sizeof(struct bt));
    p->e=e;
    e++;
    if(s[1]=='('){
      j=1;
      for(i=2;j;i++){
	if(0){
	}else if(s[i]=='('){
	  j++;
	}else if(s[i]==')'){
	  j--;
	}
      }
      e=f(a,s.substr(1,i-1),p->l,e);
    }else{
      e=f(a,s.substr(1,1),p->l,e);
    }
    if(s[s.length()-2]==')'){
      j=1;
      for(i=s.length()-3;j;i--){
	if(0){
	}else if(s[i]==')'){
	  j++;
	}else if(s[i]=='('){
	  j--;
	}
      }
      e=f(a,s.substr(i+1,s.length()-i-2),p->r,e);
    }else{
      e=f(a,s.substr(s.length()-2,1),p->r,e);
    }
  }else{
    p->l=NULL;
    p->r=NULL;
    p->a=a[s[0]-'1'][0];
    p->b=a[s[0]-'1'][1];
    p->c=a[s[0]-'1'][2];
    p->d=a[s[0]-'1'][3];
  }
  return e;
}
struct bt g(struct bt* z,int i){
  struct bt a,b,c;
  if(z->l==NULL){
    return *z;
  }else{
    a=g(z->l,i);
    b=g(z->r,i);
    if(0){
    }else if(i/(int)pow(3,z->e)%3==0){
      c.a=a.a&b.a;
      c.b=a.b&b.b;
      c.c=a.c&b.c;
      c.d=a.d&b.d;
    }else if(i/(int)pow(3,z->e)%3==1){
      c.a=a.a|b.a;
      c.b=a.b|b.b;
      c.c=a.c|b.c;
      c.d=a.d|b.d;
    }else if(i/(int)pow(3,z->e)%3==2){
      c.a=a.a^b.a;
      c.b=a.b^b.b;
      c.c=a.c^b.c;
      c.d=a.d^b.d;
    }
    return c;
  }
}
int main(){
  int i,j;
  int a[9][4],n,e;
  int sm;
  string s;
  struct bt c;
  struct bt* z;
  while(getline(cin,s)&&s!="END"){
    cin>>n;
    for(i=0;i<n;i++)
      for(j=0;j<4;j++)
	cin>>a[i][j];
    z=(struct bt*)malloc(sizeof(struct bt));
    e=f(a,s,z,0);    
    sm=0;
    for(i=0;i<(int)pow(3,e);i++){
	c=g(z,i);
	sm+=c.a&c.b&c.c&c.d;
    }
    cout<<sm<<endl;
    getline(cin,s);
  } 
  return 0;
}

Measured memory_bytes: 964
import math

n = int(input())

dp = [n] * (n+1)

dp[0] = 0
dp[1] = 1

p = int(math.log(n, 6))
q = int(math.log(n, 9))

for i in range(1, n+1):
    dp[i] = min(dp[i-1]+1, dp[i])
    for x in range(1, p+10):
        y = pow(6, x)
        if i - y >= 0:
            dp[i] = min(dp[i-y] + 1, dp[i])
        else:
            break
    for x in range(1, q+10):
        y = pow(9, x)
        if i - y >= 0:
            dp[i] = min(dp[i-y] + 1, dp[i])
        else:
            break

print(dp[n])

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n;

int main() {
	cin >> n;
	
	bool ans = false;
	incII(i, 0, 100) {
	incII(j, 0, 100) {
		if(i * 4 + j * 7 == n) { ans = true; }
	}
	}
	
	cout << (ans ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 256
def nyu():
    num1,num2 = input().split()
    num1 = int(num1)
    num2 = int(num2)
    #   print("x = " ,x[i]  ,"y = ",y[i])
    return num1,num2

def otoshidama(n,y):
    n = n+1
    ichiman = 0
    gosen = 0
    senen = 0
    y_tmp = y
    for i in reversed(range(n)):
#        print(i)
        ichiman  = 0
        gosen  = 0
        senen = 0
        y_tmp = y
        g_ymp = y_tmp 
        if y_tmp >= 10000*i: 
            y_tmp = y_tmp - 10000*i
            ichiman = i
            g_ymp = y_tmp
 #           if check(y_tmp,ichiman,gosen,senen) == True:
 #            return ichiman,gosen,senen
        for g in reversed(range(n-i)):
            gosen = 0
            senen = 0
            y_tmp = g_ymp
            if y_tmp >= 5000*g:
                y_tmp = y_tmp - 5000 * g
                gosen = g
#                if check(y_tmp,ichiman,gosen,senen) == True:
#                   return ichiman,gosen,senen
            senen = int(y_tmp / 1000)
            y_tmp = y_tmp % 1000
            if check(y_tmp,ichiman,gosen,senen) == True:
                return ichiman,gosen,senen
    return -1,-1,-1

def check(y_tmp,ichiman,gosen,senen):
    #print("y_tmp:",y_tmp,"ichiman:",ichiman,"gosen:",gosen,"senen:",senen,"goukei",ichiman + gosen + senen,n)
    if y_tmp == 0 and ichiman + gosen + senen  == n:
        return  True    
    return False


n,y =nyu()
num1,num2,num3 = otoshidama(n,y)
print(num1,num2,num3)



Measured memory_bytes: 3064
from collections import OrderedDict, deque
N = int(input())
A = OrderedDict({i: int(input()) for i in range(1, N+1)})
ans = 0

for key in range(1, N):
    ans += A[key] // 2
    A[key] %= 2
    if (A[key] == 1) & (A[key+1] > 0):
        ans += 1
        A[key+1] -= 1


print(ans + A[N]//2)

Measured memory_bytes: 51420
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"

	"github.com/emirpasic/gods/trees/redblacktree"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	h := getNextInt(scanner)
	w := getNextInt(scanner)

	rbt := redblacktree.NewWithIntComparator()
	rbt2 := redblacktree.NewWithIntComparator()
	right := make([]int, w)
	for i := 0; i < w; i++ {
		right[i] = i
		rbt.Put(i, 1)
	}
	rbt2.Put(0, w)

	for i := 0; i < h; i++ {
		a := getNextInt(scanner) - 1
		b := getNextInt(scanner)
		x := -1
		for node, ok := rbt.Ceiling(a); ok && node.Key.(int) <= b; node, ok = rbt.Ceiling(a) {
			k := node.Key.(int)
			rbt.Remove(k)
			if x < right[k] {
				x = right[k]
			}
			old, _ := rbt2.Get(k - right[k])
			if old.(int) == 1 {
				rbt2.Remove(k - right[k])
			} else {
				rbt2.Put(k-right[k], old.(int)-1)
			}
			right[k] = -1
		}
		if b < w && x != -1 {
			if right[b] < x {
				right[b] = x
			}
			rbt.Put(b, 1)
			old, found := rbt2.Get(b - right[b])
			if found {
				rbt2.Put(b-right[b], old.(int)+1)
			} else {
				rbt2.Put(b-right[b], 1)
			}
		}
		if rbt2.Empty() {
			fmt.Fprintln(writer, -1)
			continue
		}
		fmt.Fprintln(writer, rbt2.Left().Key.(int)+i+1)
	}
}


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

int main(){
    int n, y;
    std::cin >> n >> y;
    int a_max, b_max, c_max;
    a_max = y / 10000, b_max = y / 5000;
    for(int a = 0; a <= a_max; a++){
        for(int b = 0; b <= b_max; b++){
            int c = n - (a + b);
            if(c < 0) continue;
            if(a * 10000 + b * 5000 + c * 1000 == y){
                printf("%d %d %d\n", a, b, c);
                return 0;
            }
        }
    }
    printf("-1 -1 -1 \n");
    return 0;
}


Measured memory_bytes: 256
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cmath>
#include <math.h>
#include <queue>
#include <tuple>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;

using ll=long long;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <vll> vl2d;
typedef vector <vi> vi2d;
typedef vector <char> vc;
typedef vector <bool> vb;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <char,int> mci;
typedef map <int,int> mii;
typedef map <long,long> ml;
typedef map <string,string> mss;
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define foreach(x,arr) for(auto& x:arr)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define endl '\n' // Normal `cout << endl` flushes the output every time wich hit performance badly
#define INF 1000000000LL
#define MOD 1000000007ll
#define deb(x) cout<<#x<<": "<<x<<endl;
#define printArray(arr) for(auto x: arr) { cout<<x<<"\t"; }
#define printMatrix(mat) for(auto x: mat) { cout<<" "; printArray(x); cout<<endl; }
#define printMap(mmap) for(auto p: mmap) { cout<< p.first<<": "<<p.second<<endl; }
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define forch(ch,str) for(char& c : str)
#define FILL(a,b) memset(a,b,sizeof(a))
//Swift related stuff
#define append push_back
#define nil nullptr
#define guard(_condition) if (bool(_condition)){}
#define count size()
#define let const auto
#define var auto
#define startsWith(str) rfind(str, 0)
#define prq priority_queue
#define tostr(argument) to_string(argument)
#define alphabet "abcdefghijklmnopqrstuvwxyz"


int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); // Fast input
    
    double hcm, mcm, h, m;
    cin>>hcm>>mcm>>h>>m;
    vll hvc(2), mvc(2);
    double hangel = 0, mangel = 0;
    mangel = m * 6.0;
    hangel = (double) h * 30.0 + 30.0 * ((double)m/60.0);
    hangel *= M_PI/180.0;
    mangel *= M_PI/180.0;
    double hx = cos(hangel) * hcm;
    double hy = sin(hangel) * hcm;
    
    double mx = cos(mangel) * mcm;
    double my = sin(mangel) * mcm;
    double res = sqrt(pow((hx-mx), 2) + pow(hy-my, 2));
    
    cout<<setprecision(20)<<res<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#define LL long long

using namespace std;

int main() {
	LL n, current_p, current_q, current_q_recent, incCombo=0, incCombo_max=1, i;
	cin >> n;
	int q[n];
    for(i=0;i<n;i++){
		cin >> current_p;
		q[current_p-1] = i;
	}

	for(i=0;i<n;i++){

		current_q = q[i];

		if(current_q > current_q_recent){
			incCombo++;
			if(incCombo>incCombo_max)incCombo_max = incCombo;
		} else {
			incCombo = 1;
		}

		current_q_recent = current_q;
	}

	cout << (n - incCombo_max) << endl;

	return 0;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(200010)
input = sys.stdin.readline
def main():
    N, Q = map(int,input().split())
    G = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int,input().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)
    V = [0]*N
    for _ in range(Q):
        p, x = map(int,input().split())
        V[p-1] += x

    def dfs(mae,ima):
        for tsugi in G[ima]:
            if mae != tsugi:
                V[tsugi] += V[ima]
                dfs(ima,tsugi)
    dfs(-1,0)
    print(*V)
if __name__ == '__main__':
    main()


Measured memory_bytes: 268432
#include <iostream>
#include <cstring>
#include <bits/stdc++.h>
#include <cstdio>
#include <cmath>
#include <cstdlib>

using namespace std;

int main()
{
    char a;
    while(~scanf("%c",&a))
    {
        if(a==',')
            printf(" ");
        else
            printf("%c",a);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

bool dp[30009][4][1009];

int main(void)
{
    int n, cnt = 0;
    string s;
    cin >> n >> s;
    dp[0][0][0]=true;
    rep(i,n)rep(j,4)rep(k,1000){
        if(dp[i][j][k] == false) continue;
        dp[i+1][j][k] = true;
        if(j <= 2){
            dp[i+1][j+1][k*10 + (s[i] - '0')] = true;
        }
    }
    rep(i,1000){
        if(dp[n][3][i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 121800
#include <bits/stdc++.h>
#define int long long int
#define gif(a,b) (a/b +(a%b?1:0))
#define pi 3.14159265358
#define watch(x) cout<<(#x)<<" is "<<(x)<<"\n";
#define float long double
using namespace std;

int32_t main()
{   
    cin.tie(NULL);
    std::ios::sync_with_stdio(false);
   	int n;
   	cin >> n;
   	float ans = 2 * pi *n;
   	cout << ans;
    return 0;
}


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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int a[10], b[10];
int cnt = 0, prod = 1;

void dfs(int i, int e) {
	if (i == e) {
		if (prod % 2 == 0) cnt++;
		return;
	}
	int prod0 = prod;

	prod = (prod0 * (a[i] - 1)) & 1;
	dfs(i + 1, e);
	prod = (prod0 * a[i]) & 1;
	dfs(i + 1, e);
	prod = (prod0 * (a[i] + 1)) & 1;
	dfs(i + 1, e);
}

int main() {
	int n; cin >> n;
	rep(i, 0, n) cin >> a[i];
	dfs(0, n);
	cout << cnt << endl;
}


Measured memory_bytes: 256