akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://beta.atcoder.jp/contests/arc100/tasks/arc100_b>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

ll solve(){
    ll res = LINF;
    ll N; cin >> N;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    vector<ll> cusum(N+1);
    for(int i = 0; i < N;i++) cusum[i+1] = cusum[i] + A[i];
    ll Sum = accumulate(A.begin(),A.end(),0LL);
    ll midx = lower_bound(cusum.begin()+1, cusum.end(), Sum/2) - cusum.begin();
    ll th = 10;
//    for(ll m = max(midx - th,2LL); m <= min(midx+th,N-2);m++){
    for(ll m = 2; m <= N - 2;m++){
        ll Lsum = cusum[m], Rsum = Sum - Lsum;
        ll lidx = lower_bound(cusum.begin()+1, cusum.end(), Lsum/2) - cusum.begin();
        ll ridx = lower_bound(cusum.begin()+1, cusum.end(), Lsum+Rsum/2) - cusum.begin();
        for(ll l = max(lidx-th,1LL); l <= min(lidx+th,m-1);l++){
            for(ll r = max(ridx-th,m+1); r <= min(ridx+th,N-1); r++){
                ll P = cusum[l], Q = cusum[m] - cusum[l], R = cusum[r] - cusum[m], S = cusum[N] - cusum[r];
                res = min(res,max({P,Q,R,S}) - min({P,Q,R,S}));
            }
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	ll sum = 0;
	for (int i = 1; i < N + 1; i++) {
		if (i % 3 == 0 || i % 5 == 0) continue;
		sum += i;
	}
	cout << sum ;

}

Measured memory_bytes: 3636
//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 = 100005;
const lo mod = 1000000007;

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

int main(void){
	scanf("%lld",&n);
	printf("%lld\n",(n-2)*180);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
void ok() { puts("YES"); exit(0); }
void no() { puts("NO"); exit(0); }
int a, b, c, d, n;
int main() {
	scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	rep(_, 0, 2) {
		rep(i, 0, n + 1) {
			ll ql = a + 1ll * i * d - 1ll * (n - 1 - i) * d;
			ll qr = a + 1ll * i * d - 1ll * (n - 1 - i) * c;
			if (ql <= b && b <= qr) ok();
		}
		swap(a, b);
	}
	no();
	return 0;
}

Measured memory_bytes: 256
def lcs(str1, str2):
    '''文字列str1, str2の最長共通部分列(Lowest Common Subsequence, LCS)を求める
    計算量O(len(str1)*len(str2))  
    '''
    dp = [[0]*(len(str2) + 1) for _ in range(len(str1) + 1)]
    for i in range(len(str1)):
        for j in range(len(str2)):
            if str1[i] == str2[j]:
                dp[i+1][j+1] = dp[i][j] + 1
            else:
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])

    '''復元を実行
    最長の長さを求めるなら return dp[len(str1)][len(str2)] をするとよい
    '''
    res = ''
    i, j = len(str1), len(str2)
    while i > 0 and j > 0:
        if dp[i][j] == dp[i-1][j]:
            i -= 1
        elif dp[i][j] == dp[i][j-1]:
            j -= 1
        else:
            res = str1[i-1] + res
            i -= 1
            j -= 1
    return res


s = input()
if len(lcs(s, "CF")) == 2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 



int main()
{ 
    int h,w,d;
    cin>>h>>w>>d;
    P p;
    int G=h*w;
    P n[G+1];
    int k[G+1];
    for(int i=1;i<=h;i++){
        p.first=i;
        for(int j=1;j<=w;j++){
            p.second=j;
            int a;
            cin>>a;
            n[a]=p;
        }
    }
    for(int i=1;i<=G;i++){
        int j=i+d;
        if(j>G){k[i]=0;}
        else{
            int x=n[i].first-n[j].first;
            int y=n[i].second-n[j].second;
            if(x<0){x=-x;}
            if(y<0){y=-y;}
            k[i]=x+y;
        }
    }

    LL k2[G+1];
    for(int i=0;i<=G;i++){
            k2[i]=0;
    }
    for(int i=1;i<=G;i++){
        int j=i;
        if(i<=d){
            while(j+d<=G){
                k2[i]=k2[i]+k[j];
                j=j+d;
            }
        }
        else{k2[i]=k2[i-d]-k[i-d];}
    }

    int q;
    cin>>q;
    LL ans[q];
    for(int i=0;i<q;i++){ans[i]=0;}
    for(int i=0;i<q;i++){
        int l,r;
        cin>>l>>r;
        ans[i]=k2[l]-k2[r];
    }
    for(int i=0;i<q;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b && b==c){
    cout << "1" << endl;
  } else if (a==b || b==c || c==a){
    cout << "2" << endl;
  } else {
    cout << "3" << endl;
  }
}


Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}



int main() {
  string N;
  cin >> N;
  rep(i,N.size()) {
    if (N[i]=='7') {
      cout << "Yes" << endl;
      return 0;}
  }
  cout << "No" << endl;
}

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

int solve(string &s) {
  deque<char> deq;
  for(auto i: s) deq.push_back(i);
  int ans = 0;
  while(deq.size() > 1) {
    if(deq.front() == deq.back()) deq.pop_front(), deq.pop_back();
    else if(deq.front() == 'x') deq.pop_front(), ++ans;
    else if(deq.back() == 'x') deq.pop_back(), ++ans;
    else return -1;
  }
  return ans;
}

int main() {
  string s;
  cin >> s;
  cout << solve(s) << '\n';
  return 0;
}


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

int n, arr[100000];
int dp_arr[100000];

int dp(int i) {
    if (i == n - 1) {
        //   cout << i << " ZOINK\n";
        return 0;
    } else if (dp_arr[i] != -1) {
        //   cout << i << " YEET\n";
        return dp_arr[i];
    } else if (i == n - 2) {
        //   cout << i << " GOTTEEM\n";
        return abs(arr[n - 1] - arr[n - 2]);
    } else {
        //   cout << i << " ZOOP!\n";
        return dp_arr[i] = min(dp(i + 1) + abs(arr[i + 1] - arr[i]),
                               dp(i + 2) + abs(arr[i + 2] - arr[i]));
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        dp_arr[i] = -1;
    }
    return cout << dp(0) << '\n', 0;
}

Measured memory_bytes: 2560
use text_io::*;
use std::collections::HashMap;
use std::process::exit;

fn main() {
    let k:String = read!();
    let mut v:Vec<char> = k.chars().collect();
    for i in 0..v.len()/2 {
        if v[i]==v[v.len()/2-1-i]&&v[i]==v[i+v.len()/2+1]&&v[i]==v[v.len()-1-i] {
        }
        else {
            println!("No");
            exit(0);
        }
    }
    println!("Yes");
}

Measured memory_bytes: 2188
n = gets.to_i
a = gets.strip.split(' ').map(&:to_i)
count = 0
(n-2).times do |i|
  count += 1 if a[i+1] > a[i] && a[i+1] < a[i+2]
  count += 1 if a[i+1] < a[i] && a[i+1] > a[i+2]
end
puts count


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

ll timeline[30][101010];

int main(){
	ll N, C;
	cin >> N >> C;
	REP(i, 30)REP(j, 101010) timeline[i][j] = 0;
	vector<ll> s(N), t(N), c(N);
	REP(i, N){
		cin >> s[i] >> t[i] >> c[i];
		s[i]--;
		c[i]--;
		for(int j=s[i];j<=t[i]-1;j++){
			timeline[c[i]][j] = 1;
		}
	}

	/*
	REP(i, C){
		REP(j, 10){
			cout << timeline[i][j] << " ";
		}
		cout << endl;
	}
	*/
	

	ll hei = -1;
	REP(i, 101010){
		ll tmp = 0;
		REP(j, C){
			tmp += timeline[j][i];
		}
		hei = max(hei, tmp);
	}
	cout << hei << endl;
    return 0;
}

Measured memory_bytes: 26368
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a%2==1 && b%2==1) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}

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

int N, M;
vector<int> E, O;

int main() {
  cin >> N >> M;
  for(int i = 0; i < M; ++i) {
    int a; cin >> a; (a % 2 == 0 ? E : O).push_back(a);
  }
  int e = E.size(), o = O.size();
  if(o > 2) cout << "Impossible" << endl;
  else if(M == 1) {
    int a = (e != 0 ? E : O)[0];
    cout << a << endl;
    if(a == 1) {
      cout << 1 << endl;
      cout << 1 << endl;
    } else {
      cout << 2 << endl;
      cout << a - 1 << " " << 1 << endl;
    }
  } else if(o == 0) {
    for(int i = 0; i < e; ++i) cout << (i == 0 ? "" : " ") << E[i];
    cout << endl;
    cout << M << endl;
    cout << E[0] + 1;
    for(int i = 1; i < e - 1; ++i) cout << " " << E[i];
    cout << " " << E[e - 1] - 1 << endl;
  } else if(o == 1) {
    cout << O[0];
    for(int i = 0; i < e; ++i) cout << " " << E[i];
    cout << endl;
    cout << M << endl;
    cout << O[0] + 1;
    for(int i = 0; i < e; ++i) cout << " " << E[i] - (i == e - 1 ? 1 : 0);
    cout << endl;
  } else {
    cout << O[0];
    for(int i = 0; i < e; ++i) cout << " " << E[i];
    cout << " " << O[1];
    cout << endl;
    bool one = O[0] == 1;
    cout << M - (one ? 1 : 0) << endl;
    if(!one) cout << O[0] - 1 << " ";
    for(int i = 0; i < e; ++i) cout << E[i] << " ";
    cout << O[1] + 1 << endl;
  }
  return 0;
}


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

using namespace std;

string s;
int curr = 0;
int tail = -1;
int ans[100000];
bool r = true;

int main()
{
  	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);

    cin >> s;

    for (int i = 0; i < s.length(); i++)
        ans[i] = 0;

    for (int i = 0; i < s.length(); i++)
    {
        if (r)
        {
            if (s[i] == 'R')
                curr++;
            else
            {
                curr++;
                ans[i - 1] = curr / 2;
                ans[i] = (curr + 1) / 2;
                if (i != s.length() - 1 && s[i + 1] == 'L')
                {
                    tail = i - 1;
                    r = false;
                }
                curr = 0;
            }
        }
        else
        {
            if (s[i] == 'L')
                curr++;
            else
            {
                ans[tail] += (curr + 1) / 2;
                ans[tail + 1] += curr / 2;
                r = true;
                curr = 1;
            }
        }
    }

    ans[tail] += (curr + 1) / 2;
    ans[tail + 1] += curr / 2;

    for (int i = 0; i < s.length(); i++)
        cout << ans[i] << " ";

	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r,c; cin>>r>>c;
    vector<vi> table(r+1,vi(c+1));
    rep(i,r)rep(j,c){
        cin>>table[i][j];
    }
    rep(i,r)rep(j,c){
        table[i][c]+=table[i][j];
    }
    rep(j,c+1)rep(i,r){
        table[r][j]+=table[i][j];
    }
    rep(i,r+1){
        rep(j,c+1){
            if (j!=0) cout<<" ";
            cout<<table[i][j];
        }
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int N, A, B;
    cin >> N >> A >> B;

    int total = 0;

    for( int i=1; i<=N; i++ )
    {
        int sum = 0;
        int num = i;

        while(num != 0)
        {
           sum += num % 10;
           num /= 10;
        }

        if((A <= sum) && (B >= sum))
        {
            total += i;
        }
    }

    cout << total;
    return 0;
}

Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(ll __x = __start; __x < __end; __x++)

typedef pair<int, int> Edge;

int main() {
  int n, m; cin >> n >> m;
  vector<Edge> G[50];
  loop(i,0,m) {
    int a, b; cin >> a >> b; a--;b--;
    G[a].emplace_back(b, i);
    G[b].emplace_back(a, i);
  }
  
  int ans = 0;
  loop(i,0,m) {
    vector<bool> done(n, false);
    queue<int> Q;
    Q.push(0);
    done[0] = true;
    int cnt = 1;
    while (Q.size()) {
      int v = Q.front(); Q.pop();
      for (auto &&edge: G[v]) {
        if (edge.second == i) continue;
        if (done[edge.first]) continue;
        done[edge.first] = true;
        cnt++;
        Q.push(edge.first);
      }
    }
    
    ans += cnt < n;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
s = input()
len = (len(s)-1) //2
s_mae = s[0:len]
s_ato = s[len+1:]

flag = True
for i in range(len):
    if s_mae[i] != s_ato[i]:
        flag = False

if flag:
    print('Yes')
else:
    print('No')

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX

typedef long long ll;
typedef pair<int, int> ii;

int main(){

  ll h, w, n;
  cin >> h >> w >> n;
  vector<ll> a(n), b(n);
  rep(i, n){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }

  map<ii, int> mp;
  rep(i, n){
    for(int j = -1; j <= 1; j++){
      for(int k = -1; k <= 1; k++){
        ll na = a[i] + j;
        ll nb = b[i] + k;
        if(na < 1 || h - 1 <= na || nb < 1 || w - 1 <= nb) continue;
        mp[make_pair(na, nb)]++;
      }
    }
  }
  vector<ll> ans(10, 0);
  for(auto it : mp){
    ans[it.second]++;
  }
 ans[0] = (h-2)*(w-2) - mp.size();
 rep(i, 10) cout << ans[i] << endl;

  return 0;
}


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

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

    int t;
    cin >> t;
    string ans;
    while (t--) {
        ans += "ACL";
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3652
#include<cstring>
#include<climits>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<stack>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 10500;
int dp[maxn], v[maxn], w[maxn];
int main()
{
		memset(dp, 0, sizeof(dp));
		int n, W; cin >> n >> W;
		for (int i = 1; i<=n; i++) cin >> v[i]>>w[i];
		for (int i = 1; i<=n; i++)
			for (int j = W; j >= w[i]; j--)
				dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
		cout << dp[W] << endl;
}

Measured memory_bytes: 3120
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<long long>::max();
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
int h, w, n, m, k, s, t, q, ans, sum, last, cnt;
struct Edge { int to,cost; };
vector<int>vec[100010];
string str;
bool f;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Seg {
	int n;
	vector<int>node, num;
	Seg(int n_) {
		n = 1; while (n < n_)n *= 2;
		node.resize(n * 2 - 1);
		num.resize(n * 2 - 1);
		rep(i, n)node[n + i - 1] = std::numeric_limits<int>::max();
		Mfor(i, n - 2)node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
	}
	void update(int i, int x,int u) {
		i = i + n - 1;
		node[i] = x;
		num[i] = u;
		while (i > 0) {
			i = (i - 1) / 2;
			LL mn = i * 2 + 1;
			if (node[i * 2 + 1] > node[i * 2 + 2])mn = i * 2 + 2;
			node[i] = node[mn];
			num[i] = num[mn];
		}
	}
	Pll find(int i, int a, int b, int l, int r) {
		if (b < l || r < a)return Pll(INF, INF);
		if (l <= a&&b <= r)return Pll(node[i], num[i]);
		Pll v1 = find(i * 2 + 1, a, (a + b) / 2, l, r),
			v2 = find(i * 2 + 2, (a + b + 1) / 2, b, l, r);
		return (v1.fir < v2.fir ? v1 : v2);
	}
};
struct vertex {
	int l, r, deep;
	bool f = 0;
};
vertex v[100010];
Seg seg(200010);
void lca() {
	vector<int>root;
	int num = 0, deep = 0;
	root.push_back(0);
	while (root.size() != 0) {
		int u = root[root.size() - 1];
		if (v[u].f == 0) {
			v[u].l = num;
			v[u].deep = deep;
			v[u].f = 1;
		}
		v[u].r = num;
		seg.update(num,deep,u);
		num++;
		rep(j, vec[u].size()) {
			if (v[vec[u][j]].f == 0) {
				root.push_back(vec[u][j]);
				vec[u].erase(vec[u].begin()+j);
				deep++;
				break;
			}
		}
		if (seg.node[seg.n + num - 2] == deep) {
			deep--;
			root.pop_back();
		}
	}
}
int main() {
	cin >> n;
	rep(i, n) {
		cin >> k;
		rep(j, k) {
			cin >> h;
			vec[i].push_back(h);
		}
	}
	lca();
	cin >> q;
	rep(i, q) {
		LL x, y;
		cin >> x >> y;
		if (v[x].l > v[y].l)swap(x, y);
		cout << seg.find(0, 0, seg.n - 1, v[x].l, v[y].r).sec << endl;
	}
	return 0;
}



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

class Rolling_Hash{
private:
  ll n;
  static constexpr ll base1=1007,base2=2009;
  static constexpr ll mod1=(1e9+7),mod2=(1e9+9);
  vector<ll> hash1,hash2,mpow1,mpow2;
public:
  Rolling_Hash(const string& s){
    n=s.size();
    hash1.assign(n+1,0);
    hash2.assign(n+1,0);
    mpow1.assign(n+1,1);
    mpow2.assign(n+1,1);
    for(ll i=0;i<n;++i){
      hash1[i+1] = (hash1[i]*base1+s[i])%mod1;
      hash2[i+1] = (hash2[i]*base2+s[i])%mod2;
      mpow1[i+1] = (mpow1[i]*base1)%mod1;
      mpow2[i+1] = (mpow2[i]*base2)%mod2;
    }
  }
  inline auto get(ll l,ll r){
    ll lefval = hash1[r]-hash1[l]*mpow1[r-l]%mod1;
    ll rigval = hash2[r]-hash2[l]*mpow2[r-l]%mod2;
    if(lefval<0)lefval+=mod1;
    if(rigval<0)rigval+=mod2;
    return make_pair(lefval,rigval);
  }
  inline auto get_LCP(ll a,ll b){
    ll len = min( n-a+1,n-b+1 );
    ll low=0,high=len;
    while( high-low>1 ){
      ll mid=(high+low)>>1;
      if(get(a,a+mid)!=get(b,b+mid))high=mid;
      else low=mid;
    }
    return low;
  }
};

main(){

  ll n;
  string s;
  cin>>n>>s;

  Rolling_Hash rh(s);
  ll ans=0;
  rep(i,n){
    for(ll j=i+1;j<n;++j){
      ll lcp=rh.get_LCP(i,j);
      ans=max(ans,min(lcp,j-i));
    }
  }
  cout<<(ans)<<endl;

}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){   

    ll N;
    cin >> N;
    ll sum = 0;
    rep1(i, N){
        if(i % 3 == 0);
        else if(i % 5 == 0);
        else{
            sum += i;
        }
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3592
# B
N, A, B, C, D = map(int, input().split())

res = 'NO'
dif = D - C
E = abs(B - A) 

for n in range(0, N):
    min_n = (N - 1 - n) * C - n*D
    max_n = (N - 1 - n) * D - n*C
    if min_n <= E and E <= max_n:
        res = 'YES'
        break

print(res)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n;
string s;
int dp[3010][3010],sum[3010];
signed main(){
    cin>>n>>s;
    rep(i,n)dp[0][i]=1;
    rep(i,n-1){
        sum[0]=0;
        rep(j,n-i)sum[j+1]=(sum[j]+dp[i][j])%mod;
        if(s[i]=='<'){
            rep(j,n-i-1)dp[i+1][j]=(sum[n-i]-sum[j+1]+mod)%mod;
        }
        else{
            rep(j,n-i-1)dp[i+1][j]=sum[j+1];
        }
    }
    cout<<dp[n-1][0]<<endl;
    return 0;
}

Measured memory_bytes: 71936
N = int(input())
A = [int(i) for i in input().split()]

f = 0
for a in A:
    if a % 2 == 0:
        if a % 3 != 0 and a % 5 != 0:
            f = 1

if f == 1:
    print("DENIED")
else:
    print("APPROVED")




Measured memory_bytes: 38384
#include"iostream"
#include"cmath"
#include"vector"
#include"algorithm"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,y;cin>>x>>y;
    if(x==2||y==2)
    {
        cout<<"No\n";return 0;
    }
    set<int>fir,sec;
    fir.insert(1);    fir.insert(3);    fir.insert(5);
    fir.insert(7);    fir.insert(8);    fir.insert(10);
    fir.insert(12);
    sec.insert(4);sec.insert(6);  sec.insert(9);  sec.insert(11);
    if((fir.find(x)!=fir.end()&&sec.find(y)!=sec.end())||
            (fir.find(y)!=fir.end()&&sec.find(x)!=sec.end()))
    {
        cout<<"No\n";
    }
    else
    {
        cout<<"Yes\n";
    }
}




Measured memory_bytes: 256
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
const int N=3005,mod=1000000007;
int n,m,f[N][N][2],ans;

int main()
{
	scanf("%d%d",&n,&m);
	rep(i,1,n) f[0][i][0]=1;
	f[0][0][1]=1;
	rep(i,0,m-1)
		rep(j,0,n)
			rep(k,0,1)
			{
				int x=f[i][j][k];
				if(j!=0)
				{
					bool tp=j-1==0?1:k;
					f[i+1][j-1][tp]=(f[i+1][j-1][tp]+x)%mod;
					f[i+1][j][tp]=(f[i+1][j][tp]+x)%mod;
				}
				if(j!=n)
				{
					f[i+1][j+1][k]=(f[i+1][j+1][k]+x)%mod;
					f[i+1][j][k]=(f[i+1][j][k]+x)%mod;
				}
			}
	rep(i,0,n) ans=(ans+f[m][i][1])%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const int INF = 100100100;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl

int main(){
  ll N, M; cin >> N >> M;
  vector<ll> A(N); REP(i, N) cin >> A[i];
  ll res = 0;
  priority_queue<int, vector<int>> que;
  REP(i, N) que.push(A[i]);
  REP(i, M){
    int tmp = que.top() / 2;
    que.pop();
    que.push(tmp);
  }
  REP(i, N){
    res += que.top(); 
    que.pop();
  }
  cout << res << endl;
} 

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define u8 unsigned char
#define u16 unsigned short
#define u32 unsigned int
#define u64 unsigned long
#define s8 char
#define s16 short
#define s32 int
#define s64 long
#define f32 float
#define f64 double
#define forin(x,y) for(auto& x: y)
#define iter(i,c) for(auto i=0; i<c; ++i)

using namespace std;
template<class T> T max(const vector<T> &x){return *std::max_element(x.begin(), x.end());}
template<class T> T min(const vector<T> &x){return *std::min_element(x.begin(), x.end());}
template<class T> size_t argmax(const vector<T> &x){auto iter = std::max_element(x.begin(), x.end()); return std::distance(x.begin(), iter);}
template<class T> size_t argmin(const vector<T> &x){auto iter = std::min_element(x.begin(), x.end()); return std::distance(x.begin(), iter);}
template<class T> T sum(const vector<T> &x){ return std::accumulate(x.begin(), x.end());}
template <class T> void sort(vector<T> &x){sort(x.begin(), x.end());}
template <class T, class Compare> void sort(vector<T> &x, Compare comp){sort(x.begin(), x.end(),comp);}
template<class T> void len(const vector<T> &x){return x.size();}
template<class T> ostream& operator<<(ostream& os, const vector<T> &x){forin(y,x)os<<y<<" "; return os;}

template<class T, size_t SIZE> T max(const array<T,SIZE> &x){return *std::max_element(x.begin(), x.end());}
template<class T, size_t SIZE> T min(const array<T,SIZE> &x){return *std::min_element(x.begin(), x.end());}
template<class T, size_t SIZE> size_t argmax(const array<T,SIZE> &x){auto iter = std::max_element(x.begin(), x.end()); return std::distance(x.begin(), iter);}
template<class T, size_t SIZE> size_t argmin(const array<T,SIZE> &x){auto iter = std::min_element(x.begin(), x.end()); return std::distance(x.begin(), iter);}
template<class T, size_t SIZE> T sum(const array<T,SIZE> &x){ return std::accumulate(x.begin(), x.end());}
template<class T, size_t SIZE> void sort(array<T,SIZE> &x){sort(x.begin(), x.end());}
template<class T, size_t SIZE, class Compare> void sort(array<T,SIZE> &x, Compare comp){sort(x.begin(), x.end(),comp);}
template<class T, size_t SIZE> ostream& operator<<(ostream& os, const array<T,SIZE> &x){forin(y,x)os<<y<<" "; return os;}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    long double a;
    cin>>n;
    long double sum=0;
    long double A[n];
    for (int i=0;i<n;i++) {
        cin>>a;
        A[i]=a;
        sum+=a;
    }
    long double ave=sum/n;
    int ans=0;
    long double Minabs=100000;
    for (int i=0;i<n;i++) {
        if (Minabs>abs(A[i]-ave)) {
            Minabs=abs(A[i]-ave);
            ans=i;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3708
def main():
    length = int(input())
    input_str = str(input())
    
    if length % 2 == 1:
        print('No')
        return
    
    border = int(length / 2)
    first_half = input_str[:border]
    latter_half = input_str[border:]

    if first_half == latter_half:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
H, W = (int(i) for i in input().split())
N = int(input())
A = [int(i) for i in input().split()]
C = []
for i in range(N):
  for j in range(A[i]):
    C.append(i+1)
ans = [[0]*W for i in range(H)]
for i in range(H*W):
  y = i // W
  if y%2==0:
    x = i%W
  else:
    x = W-1-i%W
  ans[y][x] = C[i]
for i in range(H):
  ans[i] = [str(a) for a in ans[i]]
  print(" ".join(ans[i]))

Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define lli long long int
#define timesave ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

void solve()
{
    lli n;
    cin >> n;

    lli arr[n+5], sum = 0;
    map<lli,lli> mp;

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

    lli q, ci, bi;

    cin >> q;

    while(q--){
        cin >> bi >> ci;
        lli d = mp[bi];
        lli val = bi * mp[bi];

        mp[ci] += d;
        mp[bi] -= d;

        lli val2 = ci * d;

        sum -= val;
        sum += val2;

        cout << sum << "\n";
    }
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //timesave; 

    int tc = 1;
    //cin >> tc;
    while(tc--	) solve();
 
    return 0;
}

Measured memory_bytes: 10172
#include<iostream>
#include <cstring>
#include <stdio.h>
using namespace std;
int main()
{  
    // 整数の入力
    string a;
    cin >> a;
    int len = a.length();
    int min = 753;
    int ab = 0;
    string p;
    
    // スペース区切りの整数の入力
    for ( int i = 0 ; i < len-2 ; i++)
    {
        p = a.substr(i,3);
        ab = 753 - atoi(p.c_str());
        if(ab <=0)
        {
            ab = ab*(-1);
            
        }
        if(min >= ab)
        {
            min = ab;
        }
    }
    cout << min << endl;
  return 0;
}

Measured memory_bytes: 256
n =  int(input())

x = []
for i in range(n):
  x.append(list(map(int, input().split())))
x.sort(key=lambda x:(x[1],x[0]))

s = 0
y = 0
for i in range(n):
  s += x[i][0]
  if s > x[i][1]:
    y = 1
    print("No")
    break
if y == 0:
  print("Yes")

Measured memory_bytes: 66288
#include "bits/stdc++.h"
#define ll long long
#define FOR(x) for(ll i = 0;i<(x);i++)
#define ALL(v) (v).begin(),(v).end()


using namespace std;


int main(){
ll H,W,h,w;
cin>>H>>W>>h>>w;

ll ans = H*W - W*h -w*(H-h);

if(ans>0)
cout<<ans<<"\n";
else
cout<<0<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }


void dfs(int i, int j, int N, int M, vvi& garden) {
	if (garden.at(i).at(j) == 1) garden.at(i).at(j) = 0;
	repk(k, i - 1, i + 2) {
		repk(l, j - 1, j + 2) {
			if (k < 0 || k >= N || l < 0 || l >= M || (k == i && l == j))continue;
			cout << k << " " << l << endl;
			if (garden.at(k).at(l) == 1)dfs(k, l, N, M, garden);
		}
	}
}


int solve(int N, int M, vvi& garden) {
	int cnt = 0;
	rep(i, N) {
		rep(j, M) {
			if (garden.at(i).at(j) == 1) {
				cnt++;
				dfs(i, j, N, M, garden);
			}
		}
	}
	return cnt;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	int A, B;
	cin >> A >> B;
	cout << A * B;

	return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

//const i64 mod = 1000000007ll;
const i64 smod = 11; //  998244353ll;
//const i64 inf = 1000000007; // 10000000000000007ll;

const double eps = 1e-8;

const i64 MAXN = 4 * 1'000'000 + 6;

i64 T;

i64 n, k, c;

void divs(i64 v, set<i64>& q) {
    for (i64 i = 2; i <= sqrt(v) + 2; i++) {
        if (v % i == 0) {
            q.insert(i);
            q.insert(v / i);
        }
    }
    q.insert(v);
    q.erase(1);
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n;

    set<i64> p1;
    divs(n - 1, p1);

    i64 R = p1.size();


    set<i64> p;
    divs(n, p);

    for (auto t : p) {
        i64 v = n;
        while (v % t == 0) {
            v /= t;
        }
        if (v > t) {
            v -= v / t * t;
        }
        if (v == 1) {
            R += 1;
        }
    }


    cout << R << endl;

    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans = 0;

		if ((A >= 1 && A <= 9) && (B >= 1 && B <= 9)) {
			ans = (A * B);
		} else {
			ans = -1;
		}

		System.out.println(ans);

		sc.close();
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

ll inf = 1e9 + 7;

int main() {
    ll n;   cin >> n;
    ll *a = new ll[n+1];
    for (int i = 0; i < n+1; i++)
        a[i] = 0;
    ll b;
    for (int i = 0; i < n; i++) {
        cin >> b;
        a[b]++;
    }

    ll ans = 1;
    if (n % 2 == 1) {
        if (a[0] != 1) {
            cout << 0 << endl;
            return 0;
        }
        bool can = true;
        for (int i = 2; i <= n-1; i+=2) {
            if (a[i] != 2)
                can = false;
        }
        if (can) {
            for (ll i = 0; i < n/2; i++) {
                ans *= 2;
                ans %= inf;
             }
            cout << ans << endl;
        }
        else {
            cout << 0 << endl;
        }
    }

    else {
        bool can = true;
        for (int i = 1; i <= n-1; i+=2) {
            if (a[i] != 2) {
                can = false;
            }
        }

        if (!can) {
            cout << 0 << endl;
        }

        else {
            for (ll i = 0; i < n/2; i++) {
                ans *= 2;
                ans %= inf;
            }
            cout << ans << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!
long long pow_int(int x, int n){
  if(n==0) return 1;
  else if(n==1) return x;
  long long tmp = pow_int(x,n/2);
  if(n%2) return x * tmp * tmp;
  return tmp * tmp;
}
double pow_(int n){
  ll ip = pow_int(2,n);
  return (double)1.0/ip;
}
// double pow_(int n){
//   if(n==0) return 1.0;
//   else if(n==1) return 0.5;
//   double tmp = pow_(n/2);
//   if(n%2) return 0.5 * tmp * tmp;
//   return tmp * tmp;
// }
// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int N, K; cin >> N >> K;
  double p=0.0;
  rep(i,1,N+1){
    double q = 1.0;
    ll L = i;
    while(L<K){
      L *= 2;
      q /= 2.0;
    }
    p += q;
  }
  cout << setprecision(18) << p/N << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
class Program
 {
        static void Main()
        {
    　　    int a,b,c,res;
      		
      		string[] v = Console.ReadLine().Split(' '); //標準入力
            //int[]　int.Parse(Console.ReadLine().Split(' '));//2つ以上のスペース区切り入力の取得
            a = int.Parse(v[0]);  //数値で受け取りたい場合は変換する
            b = int.Parse(v[1]);
            c = int.Parse(v[2]);
            res = Math.Max(0,c-(a-b));
            
　　　　　　Console.WriteLine(res);//改行付き出力
        }
 }

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

int main() {
  priority_queue<int> pq;
  int n;
  cin >> n;
  for(int i=0; i<n; i++) {
    int a; cin >> a;
    pq.push(a);
  }
  int ans=0;
  bool turn=1;
  
  while(!pq.empty()) {
    ans+=pq.top()*(turn?1:-1);
    turn^=1;
    pq.pop();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

S = input()

alphas = [chr(ord('a') + i) for i in range(26)]

if len(S) < 26:
    remain = set(alphas) - set(S)
    remain = sorted(remain)
    print(S + remain[0])
else:
    pre = S[-1]
    i = 2
    while i < len(S):
        if pre < S[len(S) - i]:
            pre = S[len(S) - i]
            i += 1
        else:
            break
    if i == 26 and S[0] == 'z':
        print(-1)
        exit()
    front = S[:-i]
    back = sorted(S[-i:])
    to_be_changed = S[-i]
    for c in back:
        if c > to_be_changed:
            print(front + c)
            break






    



Measured memory_bytes: 9272
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define REPI(i,a,b) for (ll i=(a);i<(b);i++)
#define REP(i,n) REPI(i,0,n)

typedef long long int ll;

int SURP = 1000000007;

int ceil(int a,int b){
	return (a+b-1)/b;
}

int main(){
	ll N;
	cin >> N;
	string s = "";

	if(N != 0){
		while(N != 0){
			int m = N%(-2);
			if(m == -1){
				m = 1;
				N = N/(-2) + 1;
			}else{
				N = N/(-2);
			}
			s = to_string(m) + s;
		}
	}else{
		s = "0";
	}


	cout << s << endl;

	return 0;
}


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

static class Program
{
    static IEnumerable<long> Solve(int N, int[] A)
    {
        var dict = new Dictionary<int, int>();
        foreach (int a in A)
        {
            if (!dict.ContainsKey(a)) { dict[a] = 0; }
            ++dict[a];
        }
        long sum = 0;
        foreach (var value in dict.Values)
        {
            sum += Math.BigMul(value, value - 1) / 2;
        }
        var values = new long[N];
        for (int i = 0; i < N; ++i)
        {
            int value = dict[A[i]];
            values[i] = sum - Math.BigMul(value, value - 1) / 2 + Math.BigMul(value - 1, value - 2) / 2;
        }
        return values;
    }

    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int[] A = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var values = Solve(N, A);
        foreach (var value in values) { Console.WriteLine(value); }
    }
}


Measured memory_bytes: 38060
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>
#pragma comment(linker, "/STACK:836777216")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))
#define N 200005

char s[N];

int l[N];
int r[N];

int main(void) {
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	scanf("%s", &s);
	string a = (string)s;
	int pos_l = 0;
	int wd = 0;
	while (wd < m) {
		while (a[pos_l] == 'x') {
			pos_l++;
		}

		l[pos_l] = wd + 1;
		wd++;
		pos_l++;
		pos_l += k;
	}

	wd = m;
	int pos_r = n - 1;
	while (wd > 0) {
		while (a[pos_r] == 'x') {
			pos_r--;
		}

		r[pos_r] = wd;
		wd--;
		pos_r--;
		pos_r -= k;
	}


	REP(i, n) {
		if (l[i] == r[i] && l[i] != 0) {
			printf("%d\n", i + 1);
		}
	}

	//scanf("%d", &n);
}

Measured memory_bytes: 3456
n,k=map(int,input().split())
x=list(map(int,input().split()))
ans,t=3e8,0
for i in range(n-k+1):
  l=x[i]
  r=x[i+k-1]
  if l*r>=0:
    t=max(abs(l),abs(r))
  else:
    t=abs(l)+abs(r)+min(abs(l),abs(r))
  ans=min(ans,t)
print(ans)

Measured memory_bytes: 14384
#include <iostream>

using namespace std;

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

  for(int i = 1; i <= 1009; i++){
    if((int)(i * 0.08) == a){
      if((int)(i * 0.1) == b){
        cout << i << '\n';
        return 0;
      }
    }
  }

  cout << -1 << '\n';

  return 0;
}


Measured memory_bytes: 888