akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashSet;

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [usize; n],
    }
    let mut r = vec![0; n];
    let mut plus = vec![0; n];
    let mut minus = vec![0; n];
    let mut factors = HashSet::new();
    let mut max = 1;
    let s : usize = a.iter().sum();
    for i in 1..s {
        if i * i > s {
            break;
        }
        if s % i == 0 {
            factors.insert(i);
            factors.insert(s / i);
        }
    }
    for d in factors {
        if s % d != 0 {
            continue;
        }
        for i in 0..n {
            r[i] = a[i] % d;
        }
        r.sort();
        for i in 0..n {
            plus[i] = if r[i] == 0 { 0 } else { d - r[i] };
            minus[i] = r[i];
        }
        for i in 1..n {
            minus[i] += minus[i - 1];
        }
        for i in (0..n - 1).rev() {
            plus[i] += plus[i + 1];
        }
        for i in 1..n {
            if plus[i] == minus[i - 1] && plus[i] <= k {
                if d > max {
                    max = d;
                }
                break;
            }
        }
    }
    println!("{}", max);
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int MOD=1000000007;
int inf=1000000007;
signed main(){
    int n;cin>>n;
    vector<int> jpy(n,inf);
    vector<string> u(n);
    vector<double> btc(n,inf);
    rep(i,n){
        double buf;
        cin>>btc[i]>>u[i];
        if(u[i]=="BTC"){
            btc[i]*=380000;
        }
    }
    double res=0;
    rep(i,n){
        res+=btc[i];
    }
    printf("%.16lf\n",res);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int h,w;
    while(true){
        cin >> h>>w;
        if(h==0&&w==0)break;
        if(h<1||w<1)continue;
        
        for(int c=0;c<h;c++){
            for(int r=0;r<w;r++){
                if(r==0 || r== w-1 || c==0 || c==h-1){
                    cout << "#";
                }else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.length();
    vector<char> ch;
    vector<int> a;
    int seq = 0;
    rep (i, n) {
        if (s[i] == 'x') {
            seq++;
        } else {
            a.push_back(seq);
            seq = 0;
            ch.push_back(s[i]);
        }
    }
    a.push_back(seq);
    rep (i, ch.size()) eprintf("%c ", ch[i]);
    rep (i, a.size()) eprintf("%d ", a[i]);
    rep (i, ch.size()) {
        if (ch[i] != ch[i_len - 1 - i]) {
            cout << -1 << "\n";
            return 0;
        }
    }
    ll ans = 0;
    rep (i, a.size() / 2) {
        ans += abs(a[i] - a[a.size() - 1 - i]);
    }
    cout << ans << "\n";
    return 0;
}

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

int main(){
    int n; cin>>n;
    int ans=0;
    int tmp;
    vector<int>d(n);
    for(int i=0;i<n;i++){
    cin>>d.at(i);
    }
    int ma=d.at(0);
    for(int i=0;i<n;i++){
        if(ma<=d.at(i)){
        ma=d.at(i);
        ans++;}
    }
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

def rl():
    return list(map(int, input().split()))


def solve():
    n, d = rl()
    ans = 0
    for i in range(n):
        x, y = rl()
        if x**2 + y**2 <= d**2:
            ans += 1
    print (ans)






mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()


Measured memory_bytes: 74664
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define INF 1e9

static const int seed=20;
static const int D=365;
static const int ntype=26;
static int ans[D+1];
static int max_score=-INF;
static int t=100500;

class Contest{
public:
    Contest(){
        last=0;
    }
    int s[D+1];
    int c;
    int last;
};

static Contest contest[ntype+1];

void Input(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int d;
    cin>>d;
    for(int i=1;i<=ntype;++i){
        int t;
        cin>>t;
        contest[i].c=t;
    }
    for(int day=1;day<=D;++day){
        for(int type=1;type<=ntype;++type){
            int t;
            cin>>t;
            contest[type].s[day]=t;
        }
    }
}

int Score(int type){
    int sum=0;
    contest[type].last=0;
    for(int day=1;day<=D;++day){
        if(ans[day]==type){
            sum+=contest[type].s[day];
            int n=day-contest[type].last;
            sum-=contest[type].c*(n*(n+1)/2);
            contest[type].last=day;
        }
    }
    if(ans[D]!=type){
        int n=D-contest[type].last;
        sum-=contest[type].c*(n*(n+1)/2);
    }
    return sum;   
}

void Output(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    for(int d=1;d<=D;++d) cout<<ans[d]<<'\n';
}

void Init(){
    for(int d=1;d<=D;++d) ans[d]=rand()%ntype+1;
}

void Greedy(){
    vector<int> l(ntype+1,0);
    int score=0;
    for(int d=1;d<=D;++d){
        for(int i=1;i<=ntype;++i) score-=contest[i].c*(d-l[i]);
        int temp=score;
        int t=-1;
        for(int i=1;i<=ntype;++i){
            int k=contest[i].s[d]+contest[i].c*(d-l[i])+score;
            if(k>temp){
                temp=k;
                t=i;
            }
        }
        ans[d]=t;
        l[t]=d;
    }
}

void change(){
    int p=rand()%D+1;
    int temp_score=Score(ans[p]);
    int temp=ans[p];
    ans[p]=rand()%ntype+1;
    int delta=Score(ans[p])-temp_score;
    if(delta>0) max_score+=temp_score;
    else ans[p]=temp;
}

void swap(){
    int p1=rand()%D+1;
    int p2=rand()%D+1;
    while(p1==p2) p2=rand()%D+1;
    int temp_score=Score(ans[p1])+Score(ans[p2]);
    int temp=ans[p1];
    ans[p1]=ans[p2];
    ans[p2]=temp;
    int delta=Score(ans[p2])+Score(ans[p1])-temp_score;
    if(delta>0) max_score+=temp_score;
    else{
        ans[p2]=ans[p1];
        ans[p1]=temp;
    }
}

void solve(int times){
    for(int i=1;i<=ntype;++i) max_score+=Score(i);
    for(int i=0;i<times;++i){
        swap();
        change();
    }
}

int main(){
    srand(seed);
    Input();
    Greedy();
    solve(t);
    Output();
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pii pair<int,int>
#define reset(x,n) memset((x),(n),sizeof(x))
#define all(n) (n).begin(),(n).end()
#define pb push_back
#define IOS ios::sync_with_stdio(0),cin.tie(0);
int in[100005];
vector<int> E[100005];
ll dp[100005];
bool vis[100005];
ll ans=0;
ll dfs(int x){
	if(vis[x])return dp[x];
	dp[x]=0;
	vis[x]=1;
	for(auto y:E[x]){
		dfs(y);
		dp[x]=max(dp[x],dp[y]+1);
	}
	return dp[x];
}
int main(){
	IOS
	int n,m,ta,tb;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>ta>>tb;
		E[ta].pb(tb);
		in[tb]++;
	}
	for(int i=1;i<=n;i++){
		if(in[i]==0)ans=max(ans,dfs(i));
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
#define ll long long

using namespace std;

bool is_odd(int number) {
        if (number%2 == 0) {
                return false;
        }
        return true;
}

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

        int a, b;

        cin >> a >> b;

        int n;

        for(int i = min(a,b); i <= max(a,b); i++) {
                n = a * i * b;
                if(is_odd(n)) {
                        cout << "Yes" << endl;
                        return 0;
                }
        }

        cout << "No" << endl;
        return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
color = [0 for _ in range(8)]
e = 0

for a in A:
    k = a // 400
    if k < 8 and color[k] == 0:
        color[k] += 1
    elif k >= 8:
        e += 1

c = color.count(1)
y = e + c

if c == 0:
    x = 1
else:
    x = c

print(x, y)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include <vector>
using namespace std;

int main() {

  int N = 0;
  cin >> N;

  int array[N];
  int min = 101;
  int max = 0;

  int ans = 1000000;

  for (int i = 0; i < N; i++) {
    cin >> array[i];
    if (array[i] < min) {
      min = array[i];
    }
    if (array[i] > max) {
      max = array[i];
    }
  }

  for (int i = 1; i <= 100; i++) {
    int dis = 0;
    for (int j = 0; j < N; j++) {
      dis += abs(array[j] - i) * abs(array[j] - i);
    }
    if (ans > dis) {
      ans = dis;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 888
#include<iostream>

using namespace std;

int main() {
	int h, m, s;
	int sec[2], ans;
	for(int i=0; i<3; ++i) {
		for(int j=0; j<2; ++j) {
			cin >> h >> m >> s;
			sec[j] = h*3600 + m*60 + s;
		}
		ans = sec[1] - sec[0];
		cout << ans/3600 << " " << (ans/60)%60 << " " << (ans%60) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
//四則演算 #pragma GCC target("avx")
//並列計算 #pragma GCC optimize("O3")
//条件分岐を減らす #pragma GCC optimize("unroll-loops")
//浮動小数点演算 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(i) sort(i.begin(),i.end())
#define rSORT(i) sort(i.rbegin(),i.rend())
#define fSORT(i,a) sort(i.begin(),i.end(),a)
#define all(i) i.begin(),i.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
inline void print() { cout << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    string s; cin >> s;
    int n = s.length();
    int k; cin >> k;
    VS t;
    FOR(i, 0, n)eFOR(j, 1, k) {
        t.push_back(s.substr(i, j));
    }
    SORT(t);
    unique(all(t));
    cout << t[k - 1] << "\n";
    return 0;
}

Measured memory_bytes: 1660
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = a * b > c * d ? a * b : c * d;
    cout << ans << endl;
    return 0;
}

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 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; }
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 main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  
  	int n;
  	cin >> n;
  	string s,t;
  	cin >> s >> t;
  	rep(i,n){
    	cout << s[i] << t[i];
    }
  	cout << endl;
  	return 0;
}

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

using namespace std;
#define ll long long 
#define lf long double
typedef vector <ll> vi;
int main() 
{
	ll n;
	cin>>n;
	cout<<fixed<<setprecision(7);
	lf ans;
	if(n%2)
	{
		ans=(((n/2)+1)/(lf)n);
	}
	else
	{
		ans=0.5;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int tmp = sc.nextInt();
      	
      	if(tmp>=30){
        	System.out.println("Yes");
			return;
        }else{
			System.out.println("No");
			return;
		}
	}
}


Measured memory_bytes: 35664
n = int(input())
w = input()
z = w[-1]
l = [w]
for i in range(1,n):
    w = input()
    if w in l:
        print('No')
        break
    if w[0] != z:
        print('No')
        break
    z = w[-1]
    l.append(w)
else:
    print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void OUT(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void OUT(T t,Ts... ts){cout<<t<<" ";OUT(ts...);}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type FILL(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type FILL(T&t,const V&v){for(auto &e:t)FILL(e,v);}
constexpr long long INF = 1e18;

signed main(){
	int N;
	cin>>N;
	auto a = mv(N);
	cin>>a;
	int ans = 0;
	FOR(i,1,N){
		if(a[i-1]<a[i])ans++;
	}
	OUT(ans);
}


Measured memory_bytes: 3632
#include <cstdio>
#include <utility>
#include <vector>
#include <iostream>

using namespace std;

int main ()
{
  ios::sync_with_stdio(false);
  string str;
  int cint;

  getline(cin, str);

  for (int i = 0; i < (int)str.size(); i++) {
    cint = (unsigned char)str[i];
    if (cint >= 65 && cint <= 90) {
      cint += 32;
    } else if (cint >= 97 && cint <= 122) {
      cint -= 32;
    }

    cout << (char)cint;
  }

  cout << "\n";

  return 0;

}

Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#define ll long long int
#define REP(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
using namespace std;

void solve(){
string s;
cin>>s;
if(s=="ABC")
    cout<<"ARC";
else
    cout<<"ABC";

}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
//	cin >> t;
	while(t--){
		solve();
	}


	return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAXN = 3000;
const int MOD = int(1E9) + 7;
inline int add(int x, int y) {return (x + y >= MOD ? x + y - MOD : x + y);}
inline int sub(int x, int y) {return (x - y < 0 ? x - y + MOD : x - y);}
inline int mul(int x, int y) {return 1LL*x*y%MOD;}

int pw2[MAXN + 5];
void init() {
	pw2[0] = 1;
	for(int i=1;i<=MAXN;i++)
		pw2[i] = mul(2, pw2[i-1]);
}

int f[2][MAXN + 5][MAXN + 5], lst[MAXN + 5][MAXN + 5];
void update(int l, int r, int k) {
	f[0][l][r] = mul(f[0][l][r], pw2[lst[l][r] - k - 1]);
	f[1][l][r] = mul(f[1][l][r], pw2[lst[l][r] - k - 1]);
	lst[l][r] = k;
}
void transform(int &x, int &y) {
	int t = (x + y) % MOD;
	x = y = t;
}

int A[MAXN + 5], X[MAXN + 5], Y[MAXN + 5];
int main() {
	init();
	int N, Q; scanf("%d%d", &N, &Q);
	for(int i=1;i<=N;i++) scanf("%d", &A[i]);
	for(int i=1;i<=Q;i++) scanf("%d%d", &X[i], &Y[i]);
	for(int i=1;i<=N;i++)
		for(int j=i+1;j<=N;j++)
			f[0][i][j] = 1, lst[i][j] = Q + 1;
	for(int i=Q;i>=1;i--) {
		if( X[i] > Y[i] ) swap(X[i], Y[i]);
		for(int j=1;j<=X[i]-1;j++) {
			update(j, X[i], i), update(j, Y[i], i);
			transform(f[0][j][X[i]], f[0][j][Y[i]]);
			transform(f[1][j][X[i]], f[1][j][Y[i]]);
		}
		for(int j=X[i]+1;j<=Y[i]-1;j++) {
			update(X[i], j, i), update(j, Y[i], i);
			transform(f[0][X[i]][j], f[1][j][Y[i]]);
			transform(f[1][X[i]][j], f[0][j][Y[i]]);
		}
		for(int j=Y[i]+1;j<=N;j++) {
			update(X[i], j, i), update(Y[i], j, i);
			transform(f[0][X[i]][j], f[0][Y[i]][j]);
			transform(f[1][X[i]][j], f[1][Y[i]][j]);
		}
		update(X[i], Y[i], i);
		transform(f[0][X[i]][Y[i]], f[1][X[i]][Y[i]]);
	}
	int ans = 0;
	for(int i=1;i<=N;i++)
		for(int j=i+1;j<=N;j++) {
			update(i, j, 0);
			if( A[i] < A[j] ) ans = add(ans, f[1][i][j]);
			if( A[i] > A[j] ) ans = add(ans, f[0][i][j]);
		}
	printf("%d\n", ans);
}

Measured memory_bytes: 105216
#include <bits/stdc++.h>
using namespace std;
  
int main() {
	long int n,m,k,i,j,ans=0;
	cin>>n>>m>>k;
	
	long long int b[m+1]={0} ,a[n+1]={0},A[n+1]={0},B[m+1]={0};
	
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		A[i]=a[i]+A[i-1];
	}
	for(j=1;j<=m;j++){
	cin>>b[j];
	B[j]=b[j]+B[j-1];
	}
	

			j=m;
	for(i=0;i<=n;i++)
	{
	if(A[i]>k)
	break;
	
	while(B[j]>k-A[i] && j>0)
	{
		j--;
}

	if(B[j]+A[i]<=k)
	ans=max(ans,i+j);
//	cout<<ans<<" "<<j<<endl;
	}
	
cout<<ans<<endl;	
}


Measured memory_bytes: 9860
n = int(input())
s = list(input())

ss = s[::-1]

ans = 0

for i in range(1000):
    if i < 100:
        a = 0
    else:
        a = i // 100
    if i < 10:
        b = 0
    else:
        b = (i-a*100)//10
    c = i-(a*100+b*10)
    if str(a) in s and str(c) in s:
        k = s.index(str(a))
        l = n-1-ss.index(str(c))
        for j in range(k+1,l):
            if s[j] == str(b):
                ans += 1
                break
            
print(ans)

Measured memory_bytes: 42988
MAX_X = 50
n, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0] * (MAX_X * n + 1) for i in range(n + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1
for i in range(n):
    for k in range(n):
        for j in range(MAX_X * n + 1):
            if j >= x[i]:
                dp[i + 1][k + 1][j] = dp[i][k + 1][j] + dp[i][k][j - x[i]]
            else:
                dp[i + 1][k][j] = dp[i][k][j]
ans = 0
for p in range(1, n + 1):
    ans += dp[n][p][a * p]
print(ans)

Measured memory_bytes: 93148
#include <stdio.h>

int main(void)
{
    int A[800000];
    int front = 400000;
    int rear = 400000;

    int q;
    scanf("%d", &q);

    int i, op, d, x, p;
    for (i = 0; i < q; i++) {
        scanf("%d", &op);
        if (op == 0) {
            scanf("%d", &d);
            scanf("%d", &x);
            if (d == 0) {
                front -= 1;
                A[front] = x;
            } else {
                A[rear] = x;
                rear += 1;
            }
        }
        else if (op == 1) {
            scanf("%d", &p);
            printf("%d\n", A[front+p]);
        }
        else {
            scanf("%d", &d);
            if (d == 0) front += 1;
            else rear -= 1;
        }
    }
    return 0;
}


Measured memory_bytes: 3356
#include <iostream>

using namespace std;
long double s = 0,ans1 = 0,ans2 = 0;
int x[110];
int main(){
	cout.precision(20);
	int i,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> x[i];
		s += x[i];
	}
	s /= (long double)n;
	int y = (int)s;
	for(i=0;i<n;i++){
		ans1 += (x[i] - y)*(x[i] - y);
		ans2 += (x[i] - y - 1)*(x[i] - y - 1);
	}
	cout << min(ans1,ans2) << endl;
}
	

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){
    int k,n,i,max=0;
    scanf("%d%d",&k,&n);
    int a[n];
    scanf("%d",&a[0]);
    for(i=1;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]-a[i-1]>max){
            max = a[i]-a[i-1];
        }
    }
    if(k-a[n-1]+a[0]>max){
        max = k-a[n-1]+a[0];
    }
    printf("%d",k-max);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

//int r, D, n = 0;
//int B(int x) {
//	n++;
//	cout << r * x - D << "\n";
//	if (n == 10) {
//		return 0;
//	}
//	return B(r * x - D);
//}

int main() {
	/*int A, B, ans;
	cin >> A >> B;
	if (A >= 13) {
		ans = B;
	}
	else if (A >= 6 && A <= 12) {
		ans = B / 2;
	}
	else {
		ans = 0;
	}
	cout << ans;*/


	/*int x;
	cin >> r >> D >> x;
	B(x);*/



	int N, M;
	cin >> N >> M;
	vector<pair<int, int>>a(M);
	rep(i, M) {
		cin >> a[i].first >> a[i].second;
	}
	ll max = 0, min = 1000000;
	rep (i, M) {
		if (a[i].first > max) {
			max = a[i].first;
		}
		if (a[i].second < min) {
			min = a[i].second;
		}
	}
	int ans;
	if (min - max < 0) {
		ans = 0;
	}
	else {
		ans = min - max + 1;
	}
	cout << ans;

	/*ll N, M;
	cin >> N >> M;
	vector<ll>A(N);
	vector<pair<ll, ll>>B(M);
	rep(i, N) {
		cin >> A[i];
	}
	rep(i, M) {
		cin >> B[i].first >> B[i].second;
	}
	rep(i, M) {
		sort(all(A));
		rep(j, B[i].first) {
			if (A[j] < B[i].second) {
				A[j] = B[i].second;
			}
			else {
				break;
			}
		}
	}
	ll ans = 0;
	rep(i, N) {
		ans += A[i];
	}
	cout << ans;*/


	return 0;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[200005];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int min=a[1];
	int maxProfit=-1000000001;
	for(int i=2;i<=n;i++)
	{
		int temp=a[i]-min;
		if(temp>maxProfit)maxProfit=temp;
		if(a[i]<min)min=a[i];
	}
	cout<<maxProfit<<endl;

	

	return 0;
}


Measured memory_bytes: 3896
// きりみんちゃんの配信からきました
// 左右をとる+-1のしゃくとり、左がマイナスかつ右がプラスの場合には「左に行った後折り返す」vs「右に行ったあと折り返す」が発生する
// 0を含む場合の取扱いに注意
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	a := make([]int, n)
	includeZero := false
	zeroIdx := -1
	for i := 0; i < n; i++ {
		var j int
		fmt.Scan(&j)
		a[i] = j
		if j == 0 {
			includeZero = true
			zeroIdx = i
		}
	}
	if includeZero {
		// ゼロを含む場合、よくわかんなかったので近い値で更新することにした
		if zeroIdx != 0 && zeroIdx != n-1 {
			if abs(a[zeroIdx-1]) < abs(a[zeroIdx+1]) {
				a[zeroIdx] = a[zeroIdx-1]
			} else {
				a[zeroIdx] = a[zeroIdx+1]
			}
		}
	}
	ans := 10000000000000000
	r := 0
	tmp := 0
	// しゃくとりフェーズ
	for l := 0; l <= n-k; l++ {
		for r < n && r-l < k {
			r += 1
		}
		// 更新は3パターン
		if a[r-1] <= 0 {
			// 最大で0より小さい場合
			tmp = a[l] * -1
		} else if a[l] >= 0 {
			// 最小で0より大きい場合
			tmp = a[r-1]
		} else {
			// 最小が0より小さく、最大が0より大きい場合
			tmp = min(a[l]*-2+a[r-1], a[r-1]*2+a[l]*-1)
		}
		ans = min(ans, tmp)
	}
	fmt.Println(ans)
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  ll n, a, b;
  cin >> n >> a >> b;
  if ((n == 1 && a != b) || (a > b)) {
    cout << 0 << endl;
    return 0;
  }
  ll mi = a * (n-1) + b;
  ll ma = a + (n-1) * b;

  cout << ma - mi + 1 << endl;

  return 0;
}


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

using namespace std;

signed main() {
    long long n;
    cin >> n;
    int c[n], prf[n + 1], sf[n + 1];
    for (int i = 0; i < n; i++)
        cin >> c[i];
    prf[0] = 0;
    sf[n] = 0;
    for (int i = 1; i <= n; i++)
        prf[i] = __gcd(c[i - 1], prf[i - 1]);
    for (int i = n - 1; i >= 0; i--)
        sf[i] = __gcd(sf[i + 1], c[i]);
    int mx = 0;
    for (int i = 0; i < n; i++)
        mx = max(mx, __gcd(prf[i], sf[i + 1]));
    cout << mx;
    return 0;
}


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

int main()
{
    int k,n; cin >> k >> n;
    int a=0,d=0,dmax=0,a0;
    for(int i=0;i<n;i++){
        cin >> a;
        if(i==0) a0=a;
        dmax=max(a-d,dmax);
        d=a;
    }
    dmax=max(dmax,k-a+a0);
    cout << k-dmax << endl;
}

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

int selectionSort(int *a,int N){
  int minj,cnt=0;
  for(int i=0;i<N;i++){
    minj = i;
    for(int j=i;j<N;j++){
      if(a[j]<a[minj]){
        minj = j;
      }
    }
    if(minj != i){
      int num=a[minj];
      a[minj] = a[i];
      a[i] = num;
      cnt++;
    }
  }
  return cnt;
}

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

  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i] ;
  }
  int s;
  s=selectionSort(A,N);
  for(int i=0;i<N;i++){
    if(i!=N-1){
      cout << A[i] << " ";
    }else{
      cout << A[i] << endl;
    }
  }

  cout << s << endl;
  return 0;
}



Measured memory_bytes: 3100
/*
    if you can't see the repay
    Why not just work step by step
    rubbish is relaxed
    to ljq
*/
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
using namespace std;

#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define lc (rt<<1)
#define rc (rt<<11)
#define mid ((l+r)>>1)

typedef pair<int,int> pll;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll _INF = 0xc0c0c0c0c0c0c0c0;
const ll mod =  (int)1e9+7;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}
void exgcd(ll a,ll b,ll &x,ll &y,ll &d){if(!b) {d = a;x = 1;y=0;}else{exgcd(b,a%b,y,x,d);y-=x*(a/b);}}//printf("%lld*a + %lld*b = %lld\n", x, y, d);
const int MAX_N = 200025;
ll Max(ll a,ll b)
{
    if(a>b) return a;
    return b;
}
struct node
{
    int id,h;
    ll s;
}arr[MAX_N];
ll dp[MAX_N],maxx[MAX_N<<2];
void up(int rt)
{
    maxx[rt] = Max(maxx[rt<<1],maxx[rt<<1|1]);
}
void update(int rt,int l,int r,int x,ll v)
{
    if(l==r)
    {
        maxx[rt] = Max(maxx[rt],v);
        return ;
    }
    if(x<=mid) update(rt<<1,l,mid,x,v);
    else update(rt<<1|1,mid+1,r,x,v);
    up(rt);
}
ll query(int rt,int l,int r,int x,int y)
{
    if(x>r||y<l) return 0;
    if(x<=l&&r<=y)
    {
        return maxx[rt];
    }
    if(x>mid) return query(rt<<1|1,mid+1,r,x,y);
    else if(y<=mid) return query(rt<<1,l,mid,x,y);
    else return Max(query(rt<<1,l,mid,x,y),query(rt<<1|1,mid+1,r,x,y));
}
int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int n;
    ll ans = 0;
    scanf("%d",&n);
    for(int i = 1;i<=n;++i) scanf("%d",&arr[i].h);
    for(int i = 1;i<=n;++i) scanf("%lld",&arr[i].s),arr[i].id = i;
    for(int i = 1;i<=n;++i)
    {
        ll tmp = 0;
        if(arr[i].h>1)  tmp = query(1,1,n,1,arr[i].h-1);
        update(1,1,n,arr[i].h,tmp+arr[i].s);
    }
    printf("%lld\n",maxx[1]);
    //fclose(stdin);
    //fclose(stdout);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


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

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

#define pb push_back
#define in ,
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int n;
  while(cin >> n) {
    int s[n] = {}, b = 0, c = 0;
    string a;
    if(n == 0) return 0;
    cin >> a;
    rep(i, 0, 100) {
      if(a[i] == 'M') s[c]++;
      else if(a[i] == 'S') b += s[c] + 1, s[c] = 0;
      else s[c] += b + 1, b = 0;
      c++;
      if(c == n) c = 0;
    }

    sort(s, s + n);
    rep(i, 0, n) cout << s[i] << " ";
    cout << b << endl;
  }

}

Measured memory_bytes: 3196
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan =new Scanner(System.in);
		double n = scan.nextDouble();
		scan.close();
		double d = n / 2;
		int i = (int)Math.ceil(d);
		System.out.println(i);
	}
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1001001001;
const ll mod = 1000000007;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

int main() {
    ll A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    ll ans1,ans2,ans3;
    ans1 = A * X + B * Y;
    if(X > Y){
        ans2 = C * Y * 2 + A * (X - Y);
    }
    else{
        ans2 = C * X * 2 + B * (Y - X);
    }
    ans3 = C * max(X,Y) * 2;
    cout << min(min(ans1,ans2),ans3) << endl;
}

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

int main(){
    
    int N;
    int count = 0;
    int  str_n;
    std::string str;
    std::cin >> N;

    for(int i = 1 ; i <= N;i++){
        str = std::to_string(i);
        str_n = str.length();
        if(str_n % 2 == 1) count++;
    }
    std::cout << count << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
string ans="APPROVED";
int n;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n;
	while(n--){
		int a;
		cin>>a;
		if(a%2==0&&a%3&&a%5) ans="DENIED";
	}
	cout<<ans;
	re 0;
}

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

int main()
{
    string s;
    cin >> s;
    int n;
    if (s == "SSS") n = 0;
    else if (s == "SSR") n = 1;
    else if (s == "SRS") n = 1;
    else if (s == "RSS") n = 1;
    else if (s == "RSR") n = 1;
    else if (s == "SRR") n = 2;
    else if (s == "RRS") n = 2;
    else if (s == "RRR") n = 3;

    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3620
n, m = list(map(int, input().split()))
from collections import defaultdict
d = defaultdict(set)
for i in range(m):
  s, c = list(map(int, input().split()))
  d[s].add(c)

s = ""
for i in range(1, n+1):
  if i == 1 and n == 1:
    if len(d[i])==1:
      s += str(list(d[i])[0])
    elif len(d[i]) >=2:
      print(-1)
      exit()
    else:
      s += "0"
  elif i == 1 and d[i] == set():
    s += "1"
  elif i == 1 and list(d[i])[0] == 0:
    print(-1)
    exit()
  elif d[i] == set():
    s += "0"
  elif len(d[i]) >= 2:
    print(-1)
    exit()
  else:
    s += str(list(d[i])[0])

print(s)

Measured memory_bytes: 3316
package main

import "fmt"

func area(a, b int) int {
	return a * b
}

func perimeter(a, b int) int {
	return 2 * (a + b)
}

func main() {
	var a, b int
	fmt.Scanln(&a, &b)
	fmt.Println(area(a, b), perimeter(a, b))
}


Measured memory_bytes: 1084
#include <stdio.h>
#include <math.h>

int main(void){
    int a, b, k;
    scanf("%d %d %d", &a, &b, &k);
    int count = 0;
    int i;
    if(a<b)i = a;
    else i = b;
    while(1){
        if(a%i == 0 && b%i == 0)count++;
        if(count == k)break;
        i--;
    }
    printf("%d\n", i);
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll MOD = 1000000007;

ll dp[2010][2010];

ll f2(ll l, ll r, ll n, vector<pair<ll, ll>> &a) {
    if (l > r) return 0;

    if (dp[l][r] >= 0) return dp[l][r];

    ll ind = l + (n - 1 - r);

    ll ans1 = (a[ind].first * (a[ind].second - l)) + f2(l + 1, r, n, a);
    ll ans2 = (a[ind].first * (r - a[ind].second)) + f2(l, r - 1, n, a);

    return dp[l][r] = max(0LL, max(ans1, ans2));
}

void solve() {
    ll n;
    cin >> n;
    vector<pair<ll, ll>> a;

    for (ll i = 0; i < n; ++i) {
        ll x;
        cin >> x;
        a.push_back(make_pair(x, i));
    }

    memset(dp, 0, sizeof(dp));
    sort(a.rbegin(), a.rend());

    for (ll l = 0; l < n; ++l) {
        for (ll r = n - 1; r >= l; --r) {
            ll ind = l + (n - 1 - r);
            ll val = a[ind].first;
            ll pos = a[ind].second;
            ll d1 = val * abs(pos - l);
            ll d2 = val * abs(pos - r);
            dp[l + 1][r] = max(dp[l + 1][r], dp[l][r] + d1);
            if (r - 1 >= 0)
                dp[l][r - 1] = max(dp[l][r - 1], dp[l][r] + d2);
            //cout << r - 1 << " ";
        }
    }

    ll ans = 0;
    for (ll i = 0; i <= n; ++i) {
        for (ll j = 0; j <= n; ++j) {
            ans = max(ans, dp[i][j]);
        }
    }
    //ll ans = f1(0, 0, n, a);
    //ll ans = f2(0,n-1,n,a);
    // ll ans = 0;
    // for (int i = 0; i <= n; ++i) {
    //     ans = max(ans, dp[n][i]);
    // }
    cout << ans << "\n";
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int t;
    // cin >> t;

    // while (t--)
    solve();

    return 0;
}


Measured memory_bytes: 35292
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		 StringBuilder sb = new StringBuilder();
		for(int i = 0; i < S.length(); i++) {
			if(S.substring(i, i + 1).equals("0")) {
				sb.append("0");
			}else if(S.substring(i, i + 1).equals("1")) {
				sb.append("1");
			}else {
				if(sb.length() != 0) {
					sb.setLength(sb.length()-1);
				}
			}
		}
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n; string s;
  cin >> n >> s;
  vector<int> e(n+1);
  rep(i,0,n) {
    e[i+1] += e[i];
    if (s[i] == 'E') e[i+1]++;
  }
  int ans = 10000000;
  rep(i,0,n) {
    int k = i - e[i] + e[n] - e[i+1];
    ans = min(ans,k);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4832
A,B,C=list(map(int,input().split()))
prev_set=set([A,B,C])
count=0
while True:
    if A%2!=0 or B%2!=0 or C%2!=0:break
    nA=int(0.5*(B+C))
    nB=int(0.5*(A+C))
    nC=int(0.5*(A+B))
    new_set=set([nA,nB,nC])
    if prev_set==new_set:
        count=-1
        break
    A=nA;B=nB;C=nC
    count+=1
print(count)

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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    vector<int> count;
    for(int i  = 0;i  < n;i++){
        int x, y;
        cin >> x >> y;
        if(x == y) count.push_back(i);
    }
    if(count.size() < 3){
        cout << "No" << endl;
        return 0;
    }
    else{
        for(int i = 2;i < count.size();i++){
            if(count[i] - 1 == count[i - 1] && count[i - 1] - 1 == count[i - 2]){
                cout << "Yes" << endl;
                return 0;
                break;
                
            }
        }
    }
    cout << "No" << endl;
}

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

# define F first    
# define S second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

typedef pair <int, int> pii; 
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") { 
  if (fopen (in, "r"))
    freopen (in, "r", stdin);
  else
    cerr << "Warning: Input file not found" << endl;
}
   
int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  int n; cin >> n;
           
  ll ans = 0;
  ll sum = 0;
  for (int i = 1; i <= n; i++) {
    int x; cin >> x;
    sum += x;
    if (!x || i == n) {
      ans += sum/2;
      sum = 0;
    }
  }          
  cout << ans;
    

  return 0;
}






// Coded by Z..


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

int main() {
    int64_t n = 0;
    int64_t a[100000];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];

    for (int i = 0; i < n; i++) {
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    int64_t ans = 1;
    for (int i = 0; i < n; i++) {
        if (a[i] > 1000000000000000000 / ans) {
            cout << -1 << endl;
            return 0;
        } else {
            ans *= a[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4412
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N;
long long x;
vector<int> vec;

const int MAX_S = 5000;
struct SparseTable {
    static const int LOG_MAX_S = 14;
    int st[LOG_MAX_S][MAX_S*2];
    int ln[MAX_S];
    
    void init(const vector<int> &vec) {
        for (int i = 0; i < MAX_S; ++i) {
            st[0][i] = 1<<30;
            int ti = i, tln = 0;
            while (ti > 0) ti /= 2, ++tln;
            ln[i] = tln - 1;
        }
        for (int i = 0; i < vec.size(); ++i) st[0][i] = vec[i];
        for (int i = 1; i < LOG_MAX_S; ++i) {
            for (int j = 0; j < MAX_S; ++j) {
                st[i][j] = min(st[i-1][j], st[i-1][j + (1<<(i-1))]);
            }
        }
    }
    
    // [a, b)
    int get(int a, int b) {
        if (a >= b) return 1<<30;
        int bet = b - a, row = ln[bet];
        return min(st[row][a], st[row][b - (1<<row)]);
    }
    
} st;

long long solve() {
    long long res = 1LL<<59;
    st.init(vec);
    
    for (int con = 0; con < N; ++con) {
        long long tmp = x * con;
        for (int i = 0; i < N; ++i) {
            int Min = 1<<30;
            if (con <= i) chmin(Min, st.get(i-con, i+1));
            else {
                chmin(Min, st.get(0, i+1));
                chmin(Min, st.get(N-(con-i), N));
            }
            //cout << con << ", " << i << ": " << Min << endl;
            tmp += Min;
        }
        //cout << tmp << endl << endl;
        chmin(res, tmp);
    }
    return res;
}

int main() {
    while (cin >> N >> x) {
        vec.clear();
        for (int i = 0; i < N; ++i) {
            int a; cin >> a;
            vec.push_back(a);
        }
        cout << solve() << endl;
    }
}





Measured memory_bytes: 640