akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
#include <deque>
#include <math.h>
#include <tgmath.h>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

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

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

//fast power
ll calc(ll a, ll b) {
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        ll d = calc(a, b / 2);
        return (d * d) % MOD;
    }
    else return (a * calc(a, b - 1)) % MOD;
}

//fast combination
ll comb(ll n, ll a) {
    ll b = 1, c = 1;
    for (ll i = 1; i <= a; ++i) {
        b = b * i % MOD;
        c = c * (n - i + 1) % MOD;
    }

    return c * calc(b, MOD - 2) % MOD;
}

ll comb2(ll a) {
    ll b = a / 2;
    if (a % 2) {
        b = (a - 1) / 2;
        return (b * a);
    }
    return (b * (a - 1));
}

int kyotsu(string ss, int st, int ed, string ss2) {
    int ans = 0;
    for ( int i = st; i < ed; ++i ) {
        if (i - st >= ss2.size()) return ans;
        if (ss[i] == ss2[i - st] || ss[i] == '?') {
            ans++;
        } else {
            return -1;
        }
    }
    return ans;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> w;
    vector<vector<ll>> aa(n, vector<ll>(2, 0));
    b = 0;
    rep (i, 0, n) {
        cin >> aa[i][0] >> aa[i][1];
        b += aa[i][1];
    }

    vector<vector<ll>> dp(n + 1, vector<ll>(b + 1, 1000000001));
    dp[0][0] = 0;

    rep (i, 0, n) {
        rep (j, 0, b + 1) {
            if (j - aa[i][1] >= 0)
                chmin(dp[i + 1][j], dp[i][j - aa[i][1]] + aa[i][0]);
            chmin(dp[i + 1][j], dp[i][j]);
        }
    }

    /*rep (i, 0, n + 1) {
        rep (j, 0, b + 1) cout << dp[i][j] << ' ';
        cout << endl;
    }*/
    rep (i, 0, b + 1) if (dp[n][i] <= w) r = i;
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
制約のn*mとn,mを読み違えない
操作の逆順を考える
オーバーフローしないか確かめる
Codeforcesではscanfを使う
modの引き算には+modをする
エラー出力は消す
エラー出力を消せ！！！！！
数値の区切り位置を誤読しない
cout << fixed;
cout << setprecision(n) << ans;
 */

int main() {
    string s,t;
    cin >> s >> t;
    int n=s.length();
    map<char,char> m;
    map<char,char> p;
    rep(i,26){
        char c='a'+i;
        m[c]='1';
        p[c]='1';
    }
    rep(i,n){
        if(m[s[i]]=='1')m[s[i]]=t[i];
        else{
            if(m[s[i]]!=t[i]){
                cout << "No";
                return 0;
            }
        }
        if(p[t[i]]=='1')p[t[i]]=s[i];
        else{
            if(p[t[i]]!=s[i]){
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";



    
}

/*
*/


Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

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

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int A,B,n;cin>>A>>B>>n;
  vector<int> a(A);rep(i,A)cin>>a[i];
  vector<int> b(B);rep(i,B)cin>>b[i];
  
  int tmp = INF;
  rep(i,n){
    int x,y,c;cin>>x>>y>>c;
    chmin(tmp,a[x-1]+b[y-1]-c);
  }
  sort(all(a));
  sort(all(b));
  int ans = tmp;
  chmin(ans,a[0]+b[0]);
  print(ans);
  return 0;
}

Measured memory_bytes: 4048
def solve():
    N, C = map(int, raw_input().split())
    xs, vs = [], []
    for i in range(N):
        x, v = map(int, raw_input().split())
        xs.append(x)
        vs.append(v)
    xs, vs = map(list, zip(*sorted(zip(xs, vs), key=lambda _: _[0])))
    a = f(xs, vs, N, C)
    b = f(map(lambda x: C-x, xs[::-1]), vs[::-1], N, C)
    ans = max(a, b)
    return ans

def f(xs, vs, N, C):
    ws = []
    best = 0
    cur = 0
    px = C
    for i in range(N-1,-1,-1):
        x, v = xs[i], vs[i]
        cur += v - abs(x-px)
        best = max(best, cur)
        px = x
        ws.append(best)
    ws = ws[::-1]
    best = 0
    cur = 0
    px = 0
    for i in range(N):
        x, v = xs[i], vs[i]
        cur += v - abs(x-px)
        best = max(best, cur)
        if i+1 < N:
            best = max(best, cur+ws[i+1]-x)
        px = x
    return best

print solve()

Measured memory_bytes: 28724
n = int(input())
As = list(map(int, input().split()))
# from math import gcd
def gcd(n, m):
    # 最大公約数
    a = max(n,m)
    b = min(n,m)
    while b:
        a, b = b, a % b
    return a
# 左からの累積GCDと
g = As[0]
left = []
for a in As:
    g = gcd(g, a)
    left.append(g)
# 右からの累積GCD
As_r = As[::-1]
g_r = As_r[0]
right = []    
for a in As_r:
    g_r = gcd(g_r, a)
    right.append(g_r)
    
l = left
r = right[::-1]
ans = 0
for i in range(n):
    if i == 0:
        ans = max(ans, r[1])
    elif i == n-1:
        ans = max(ans, l[n-2])
    else:     
        g = gcd(l[i-1],r[i+1])
        ans = max(ans, g)
print(ans)

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

const int INF = (int)2e9;
int N, K;
vector<int> A;
int G;
int min_a0, min_a1, max_a;
bool f_exist = false;

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

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

	A.resize(N);
	min_a0 = min_a1 = INF;
	max_a = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		if (A[i] == K)
			f_exist = true;
		if (A[i] > max_a)
			max_a = A[i];
		if (A[i] < min_a1)
			min_a1 = A[i];
		if (min_a1 < min_a0)
			swap(min_a1, min_a0);
	}

	if (f_exist) {
		cout << "POSSIBLE\n";
		return 0;
	}

	if (max_a < K) {
		cout << "IMPOSSIBLE\n";
		return 0;
	}

	G = gcd(min_a0, min_a1);
	for (int i = 0; i < N; ++i) {
		if (A[i] % G != 0)
			G = gcd(G, A[i]);
	}

	if (K % G == 0)
		cout << "POSSIBLE\n";
	else
		cout << "IMPOSSIBLE\n";
	return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;
    int cnt = 0;
    REP(i, N) {
        if (S[i] == '.') {
            cnt++;
        }
    }
    int res = cnt;
    int w = 0, b = 0;
    REP(i, N) {
        if (S[i] == '.') {
            w++;
        } else {
            b++;
        }
        amin(res, b + cnt - w);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <vector>
using namespace std;

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define PB push_back
typedef long long ll;

int main(){
	ll a,b;
	cin >>a>>b;
	if(a<=0 && b>=0)cout << "Zero";
	else if(a<0 && b<0){
		if(llabs(a-b)%2)cout << "Positive";
		else cout <<"Negative";
	}
	else cout << "Positive";
	cout <<endl;


	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100
int main(){
  int i,j,n,A[N],temp,minj,cunt = 0;
  scanf("%d",&n);
  for(i = 0; i < n;i++){
    scanf("%d",&A[i]);
  }
  for(i =  0;i <= n-1;i++){
    minj = i;
    for(j =  i;j <= n-1;j++){
      if (A[j] < A[minj]){
	minj = j;
      }
    }
    if(A[i] > A[minj])cunt++;
    temp = A[minj];
    A[minj] = A[i];
    A[i] = temp;
    
  }
  for(i = 0;i < n;i++){
    if(i) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d",cunt);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define rg register
#define ll long long 
#define maxn 233333
inline ll read()
{
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            f=-1;
        }
        c=getchar();
    } 
    while(c<='9'&&c>='0')
    {
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return x*f;
}
ll n;
ll tot;
int main()
{
	n=read();
	for(rg int i=n;i>=1;--i)
	{
		ll res=i,flag=0;
		while(res)
		{
			flag++;
			res/=10;
		}
		if(flag%2!=0) ++tot;
	}
	cout<<tot;
}

Measured memory_bytes: 256
from math import factorial, sqrt

n, m = map(int, input().split())


ans = 1

if m != 1:
    factorization = {}
    while True:
        for i in range (2, int(sqrt(m))+1):
            if m % i == 0:
                if i in factorization:
                    factorization[i] += 1
                else:
                    factorization[i] = 1
                m = m // i
                break
        else:
            if m in factorization:
                    factorization[m] += 1
            else:
                factorization[m] = 1
            break


    for i in factorization.keys():
        k = factorization[i]

        num = 1
        for i in range(k):
            num *= (n+k-1-i)
        num //= factorial(k)
        ans *= num % (10**9+7)
        ans = ans % (10**9+7)



print(ans)





Measured memory_bytes: 3064
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int MOD=1000000007;

int main(){
    ll n;
    cin>>n;
    cout<<(n-1)*n/2<<endl;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int f(int x){
  string s=to_string(x);
  rep(i,0,s.size()){
    if(s[i]!=s[0])return 0;
  }
  return 1;
}
signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N; cin >> N;
  while(!f(N))N++;
  cout<<N<<endl;
  


    return 0;
}


Measured memory_bytes: 256
#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>;

const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
vector<ll> dp(100010,0);
vector<ll> a(100010);

void print_vec(vector<ll> vec,int n) {
    rep(i,n) cout << vec.at(i) << " ";
    cout << endl;
}

int main() {
    int N,M; cin >> N >> M;
    rep(i,M) cin >> a.at(i);
    rep(i,M) dp.at(a.at(i)) = -1;
    dp[0] = 1;
    //rep(i,N+1) cout << dp.at(i) << " ";
    //cout << endl; 
    for(int i = 1; i < N+1; i++) {
        if(dp[i] != -1) {
            if(dp[i-1] != -1) dp[i] += dp[i-1] % MOD;
            if(dp[i-2] != -1 && i > 1) dp[i] += dp[i-2] % MOD;
        }
        //print_vec(dp,N+1);
    }
    cout << dp[N] % MOD << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

ll f(ll n) {
  if(n%2) return 3*n+1;
  else return n/2;
}

int main() {
  ll s;
  cin >> s;
  set<ll> cnt;
  cnt.insert(s);
  ll m=1;
  while(m++) {
    s=f(s);
    if(cnt.count(s)) {
      cout << m << endl;
      return 0;
    }
    else {
      cnt.insert(s);
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
using namespace std;
 
int main(){

int antena[5];
int k;

for(int i=0;i<5;i++){
cin>>antena[i];
}
cin>>k;

for(int i=0; i<5; i++){
    for(int j=0;j<5;j++){
        if(i != j){
        if((antena[j] - antena[i]) > k){
            cout << ":(" << endl;
            return 0;
        }
        }
    }
}
    cout << "Yay!" << endl;
}

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

void solve(long long D){
	string s = "Christmas";
	for(int i = 0; i < 25 - D; ++i) {
		s = s + " Eve";
	}
	cout << s << endl;
}

int main(){	
	long long D;
	scanf("%lld",&D);
	solve(D);
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<climits>
#include<map>
#define ll long long
using namespace std;
int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	if (a == b&&c>0) {
		cout << "NO" << endl;
		exit(0);
	}
	for (ll i = 1; i < 100000000; i++) {
		if ((a*i) % b == c)  {
			cout << "YES" << endl;
			exit(0);
		}
	}
	cout << "NO" << endl;
}



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

using namespace std;
using ll = long long;

int main() {
	ll x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int> red(a), gre(b), nun(c);
	rep(i, a) cin >> red[i];
	rep(i, b) cin >> gre[i];
	rep(i, c) cin >> nun[i];
	sort(red.rbegin(), red.rend());
	sort(gre.rbegin(), gre.rend());
	sort(nun.rbegin(), nun.rend());
	int nx = x - 1;
	int ny = y - 1;
	rep(i, c) {
		if (nx >= 0 && ny >= 0) {
			if (red[nx] < gre[ny] && red[nx] < nun[i]) {
				red[nx] = nun[i];
				nx--;
			}
			else if (gre[ny] < nun[i]) {
				gre[ny] = nun[i];
				ny--;
			}
		}
		else if (nx >= 0 && red[nx] < nun[i]) {
			red[nx] = nun[i];
			nx--;
		}
		else if (ny >= 0 && gre[ny] < nun[i]) {
			gre[ny] = nun[i];
			ny--;
		}
	}
	ll ans = 0;
	rep(i, x) ans += red[i];
	rep(i, y) ans += gre[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4524
n = int(input())
s = input()
cum_sum = [0]*(n+1)

for i in range(n):
    if s[i] == "E":
        cum_sum[i+1] += 1
    cum_sum[i+1] += cum_sum[i]

INF = 10**18
ans = INF
for i in range(1, n+1):
    ans = min(ans, (((i-1)-cum_sum[i-1])+(cum_sum[n]-cum_sum[i])))

print(ans)


Measured memory_bytes: 15264
//#include <bits/stdc++.h>                          //include all library
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <string.h>
#include <functional> // greater<int> はfunctionalヘッダ
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)          //REP(i, 10){...} //i=0～i=9までのループ
#define REPR(i, n) for(int i = n;i >= 0;i--)        //REPR(i, 10){...} //i=10～i=0までのループ
#define FOR(i, m, n) for(int i = m;i < n;i++)       //FOR(i, 3, 10){...} //i=3～i=9までのループ
#define FORR(i, m, n) for(int i = m;i >= n;i--)     //FORR(i, 10, 3){...} //i=10～i=3までのループ
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define PI 3.141592653589
#define npos -1

int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  if(a!=b and b==c) cout << a;
  else if(a!=c and a==b) cout << c;
  else cout << b;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

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

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<pair<ll, ll> > v(n);
    rep (i, n) cin >> v[i].second >> v[i].first;
    sort(v.begin(), v.end());
    ll now = 0;
    rep (i, n) {
        ll dead = v[i].first, cost = v[i].second;
        if (now > dead || now + cost > dead) {
            cout << "No" << endl;
            return 0;
        }
        now += cost;
    }
    cout << "Yes" << endl;
    
    return 0;
}



Measured memory_bytes: 3456
#include <stdio.h>
#include <string.h>
int main(){
	char entrada[10], *dia[8] = {"", "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
	int resp = 0;
	scanf("%s", entrada);
	for(int i = 0; i < 8; ++i){
		if(strcmp(dia[i], entrada) == 0){
			resp = i;
			break;
		}
	}
	printf("%d\n", resp);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;

typedef long long ll;
ll n, s, l[N], r[N];
int main()
{
	ll i;
	cin >> n;
	l[0] = r[0] = 0;
	for (i = 1; i <= n; i++) {
		scanf ("%lld %lld", &l[i], &r[i]);
	}
	sort(l, l + n + 1, greater<ll>());
	sort(r, r + n + 1);
	for (i = 0; i <= n; i++) {
		if(l[i] - r[i] < 0) break;
		s += l[i] - r[i];
	}
	cout << s * 2;
    return 0;
}


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

typedef long long ll;

int main() {
  int N; cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  
  ll ans = 0;
  for (int i = 1; i < N; i++) {
    if (A[i-1] > A[i]) {
      ll num = A[i-1] - A[i];
      ans += num;
      A[i] = A[i-1];
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 4844
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;
const int INF = 0x2fffffff;

struct Edge {
  int to;
  int v;
};

int N;
vector<Edge> es[114514];
vector<Edge> des[114514];
int cnt[16];
int dp[1 << 16];
bool allowed[1 << 16];

void Dfs(int v, int p, int av) {
  int tot = 0;
  for (auto &e : es[v]) {
    int u = e.to;
    if (u == p) continue;
    Dfs(u, v, e.v);
    tot ^= e.v;
  }
  if (av != -1) cnt[av^tot]++;
}


int main() {
  scanf("%d", &N);
  rep(i, N-1) {
    int u, v, a;
    scanf("%d%d%d", &u, &v, &a);
    es[u].eb(Edge{v, a});
    es[v].eb(Edge{u, a});
  }

  Dfs(0, 0, -1);

  int lim = 1 << 15;
  rep(st, lim) {
    int tot = 0;
    rep(i, 15) {
      if (st >> i & 1) tot ^= i+1;
    }
    allowed[st] = (tot == 0);
  }

  fill(dp, dp+lim, MOD);
  rep(st, lim) {
    dp[st] = __builtin_popcount(st);
    rrep(sub, st+1) {
      sub &= st;
      if (!allowed[sub]) continue;
      if (sub == 0) continue;
      MN(dp[st], dp[st ^ sub] + __builtin_popcount(sub) - 1);
    }
  }

  int ans = 0;
  int st = 0;
  reps(i, 1, 16) {
    ans += cnt[i]/2;
    st += (cnt[i]%2) << (i-1);
  }
  //printf("dp[%d]: %d\n", st, dp[st]);
  printf("%d\n", ans + dp[st]);
}


Measured memory_bytes: 14848
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>

using namespace std;

#define EPS	1.0e-10
#define rep(idx, max)	for(int idx = 0, idx##Max = max; idx < idx##Max; idx ++)
#define rrep(idx, min, max)	for(int idx = min, idx##Max = max; idx < idx##Max; idx ++)
#define erep(idx, min, max)	for(int idx = min, idx##Max = max; idx <= idx##Max; idx ++)

#define rev(idx, max)	for(int idx = max - 1; idx >= 0; idx --)

#define foreach(it, o)	for(auto it = (o).begin(), it##End = (o).end(); it != it##End; it ++)

#define SORT_INCORDER(v)	std::sort((v).begin(), (v).end())
#define SORT_DECORDER(v)	std::sort((v).begin(), (v).end(), std::isgreater<int>())


typedef unsigned int UINT;
typedef std::vector<int>	VEC;

/*
* ?´???°?????????
* @param (dst) ?´???°?????????????????????
* @param (n) ?????§???
*/
void	GetPrime(VEC &dst, int n)
{
	VEC bIsPrime(n);

	rep(i, n) { bIsPrime[i] = (i & 0x01); }
	bIsPrime[1] = false;
	bIsPrime[2] = true;
	for (int i = 2; i * i < n; i++)
	{
		if (!bIsPrime[i]) { continue; }
		for (int j = i * i; j < n; j += i)	{	bIsPrime[j] = false;	}
	}

	dst.clear();
	rep(i, n) { if (bIsPrime[i]) { dst.push_back(i); } }
}

#define MAX_TERM	100
#define MAX_NUMS	2e+5

int main(int nArgs, char **lplpszArgs)
{
	VEC	primes;
	vector<int>	sums;
	
	int	bottomNum, term;

	::GetPrime(primes, MAX_NUMS);

	while (cin >> bottomNum >> term, bottomNum != -1)
	{
		int	idxStart = 0;	// bottomNum??\???????´???°?????????????????????
		rep(i, MAX_NUMS)
		{
			if (bottomNum < primes[i]) { idxStart = i; break; }
		}
		erep(i, idxStart, idxStart + term - 1)
		{
			erep(j, i, idxStart + term - 1)
			{
				sums.push_back(primes[i] + primes[j]);
			}
		}
		
		SORT_INCORDER(sums);
		//rep(i, term){	::printf("[%d]", sums[i]);	}	::puts("");

		::printf("%d\n", sums[term - 1]);
		sums.clear();
	}
}

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

int main(){
  int n, cnt[50][26] = {};
  string s, ans = "";
  
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> s;
    for(int j = 0;j < s.size();j++) cnt[i][s[j] - 'a']++;
  }
  
  for(int i = 0;i < 26;i++){
    int x = 50;
    for(int j = 0;j < n;j++) x = min(x, cnt[j][i]);
    for(int j = 0;j < x;j++) ans += (char)(i + 'a');
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>

using namespace std;

int main(){
    long long n; cin >> n;
    string s = to_string(n);
    if(s.length() == 1){
        cout << n << endl;
        return 0;
    }
    long long sum = 0;
    for(int bit = 0; bit < 1 << (s.length()-1);bit++){
        int l = 0;
        for(int r = 0; r < s.length(); r++){
            if(bit & 1 << r){
                sum += stoll(s.substr(l,r-l+1));
                l = r + 1;
            }
        }
        sum += stoll(s.substr(l,s.length()-l));
    }
    cout << sum << endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    vector<int>b(n);
    rep(i,n)b[i] = a[i];
    sort(all(b));
    int max = b[n-1];
    int max2 = b[n-2];
    rep(i,n){
        if(a[i] == max)cout << max2 << endl;
        else cout << max << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vi c(n);
    vvi a(n, vi(m));
    rep(i, n) {
        cin >> c[i];
        rep(j, m) {
            cin >> a[i][j];
        }
    }

    int ans = INT_MAX;
    rep(i, 1<<n) {
        vi xx(m);
        int mi=0;
        rep(j, n) {
            if((i>>j)&1) {
                mi += c[j];
                rep(k, m) {
                    xx[k] += a[j][k];
                }
            }
        }
        rep(j, m) {
            if(xx[j] < x){
                goto OUT;
            }
        }
        ans = min(ans, mi);

        OUT:;
    }

    if(ans == INT_MAX) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;
signed main(){
    int N,K;cin>>N>>K;
    int S[N+1];
    REP(i,N+1)S[i]=0;
    REPS(i,N){
        int a;cin>>a;
        S[i]=(S[i-1]+a-1)%K;
        while(S[i]<0)S[i]+=K;
    }
    int ans=0;
    map<int,int>memo;
    REPS(j,N){
        if(j==1){
            for(int i=max(0ll,j-K+1);i<j;i++){
                memo[S[i]]++;
            }
        }
        else{
            if(j-K>=0)memo[S[j-K]]--;
            memo[S[j-1]]++;
        }
        ans+=memo[S[j]];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 14336
//AtCoder Beginner Contest 085
//B - Kagami Mochi

#include <iostream>
#include <algorithm>

using namespace std;

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

    int d[n];
    for(int i=0;i<n;i++){
        cin >> d[i];
    }
    sort(d, d+n, greater<int>());

    int x = 1;
    int now = d[0];
    for(int i=1;i<n;i++){
        if(now!=d[i]){
            x++;
            now = d[i];
        }
    }

    cout << x << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <utility>
#include <bitset>
using namespace std;
typedef long long ll;
const ll inf = 4e18;
const ll mod = 1e9+7;
#define print(X) cout << (X) << endl
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (ll (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define repd(i, m, n) for (ll (i) = (m); (i) > (n); --(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

int main(void)
{
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    print(min(A,B)+min(C,D));
}


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

typedef pair<int, long long> pil;

bool cmp(pil lhs, pil rhs)
{
	return (lhs.first < rhs.first);
}

int main()
{
	int n;
	while (cin >> n, n){
	
	vector<pil> p(n);
	
	int cnt = 0;
	for (int i = 0; i < n; i++){
			int a, b, c;
			bool f = true;
			cin >> a >> b >> c;
			for (int j = 0; j <= cnt; j++){
				if (p[j].first == a){
					p[j].second += b * c;
					f = false;
				}
			}
			if (f){
				p[cnt].first += a;
				p[cnt].second += b * c;
				cnt++;
			}
		}
		bool fl = true;
		for (int i = 0; i < cnt; i++){
			if (1000000 <= p[i].second){
				cout << p[i].first << endl;
				fl = false;
			}
		}
		if (fl){
			cout << "NA" << endl;
		}
	}
	return (0);
}

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

typedef long long ll;

int main() {
	int n;
	cin >> n;
	int A[n + 2];
	ll ans = 0;
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	ll dp[n + 2];
	dp[n - 1] = 0;
	for(int i = n - 2; i >= 0; i--){
		dp[i] = dp[i + 1] + abs(A[i] - A[i + 1]);
		if(i < n - 2) dp[i] = min(dp[i], dp[i + 2] + abs(A[i] - A[i + 2]));
	}
	cout << dp[0] << '\n';
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cmath>

using namespace std;
long long int a[100000];
long long int dp[1000005];
//long long int dp2[1000001];
/*long long int dp(long long int current,long long int length){
if(current==length-2){
    return abs(a[length-1]-a[length-2]);
}
if(current==length-3){
    long long int numb1=abs(a[length-1]-a[length-3]);
    long long int numb2=abs(a[length-1]-a[length-2])+abs(a[length-2]-a[length-3]);

    if(numb1<numb2){
        return numb1;
    }
    else
       return numb2;
}
else{
    long long int numb1=dp(current+1,length);
    long long int numb2=dp(current+2,length);
    if(numb1<numb2){
        return abs(a[current+1]-a[current])+numb1;
    }
    else{
        return abs(a[current+2]-a[current])+numb2;
    }
}

}*/

int main()
{
    long long int length ,step;
    cin >> length >>step;
    for(long long int i=0;i<length;i++){
        cin >>a[i];
    }
    dp[0] = 0;
    for(int i = 1; i < length; i++){
        dp[i] = dp[i-1] + abs (a[i] - a[i-1]);
        if(i > 1){
                for(int j=2;j<=step&&j<=i;j++)
            dp[i] = min(dp[i], dp[i-j] + abs(a[i] - a[i-j]));
        }
    }
     cout<<dp[length-1]<<endl;

    //cout<<dp(0,length)<<endl;
}


Measured memory_bytes: 5176
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>
using namespace std;
const int INF=1e9;
int n;
void Clear(vector<int>& vec)
{
	vector<int>tmp;
	swap(vec,tmp);
	return ;
}
struct Tree{
	vector<int>to[110];
	void build(int u,int v)
	{
		to[u].push_back(v);
		return ;
	}
	void adde(int u,int v)
	{
		build(u,v);
		build(v,u);
		return ;
	}
	int fa[110];
	void clear()
	{
		for(int i=1;i<=n;i++)
		{
			Clear(to[i]);
			fa[i]=0;
		}
		return ;	
	}
	void dfs(int u,int lst=0)
	{
		fa[u]=lst;
		for(int i=0;i<to[u].size();i++)
			if(to[u][i]!=lst)dfs(to[u][i],u);
		return ;
	}
}TA,TB;
struct Graph{
	vector<int>to[110];
	int deg[110];
	void build(int u,int v)
	{
		to[u].push_back(v);
		deg[v]++;
		return ;
	}
	void clear()
	{
		for(int i=1;i<=n;i++)
		{
			Clear(to[i]);
			deg[i]=0;
		}
		return ;
	}
	bool check()
	{
		queue<int>q;
		for(int i=1;i<=n;i++)
			if(!deg[i])q.push(i);
		while(!q.empty())
		{
			int u=q.front();
			q.pop();
			for(int i=0;i<to[u].size();i++)
			{
				int v=to[u][i];
				deg[v]--;
				if(!deg[v])q.push(v);
			}
		}
		for(int i=1;i<=n;i++)
			if(deg[i])return false;
		return true;
	}
}G;
bool need(int u)
{
	return TA.fa[u]!=TB.fa[u];
}
int U[110],V[110];
int Deg[110];
int work(int u,int v)
{
	TA.clear();
	TA.adde(u,v);
	for(int i=1;i<n;i++)
	{
		if(U[i]==u||V[i]==u)continue;
		TA.adde(U[i],V[i]);
	}
	TA.dfs(u);TB.dfs(u);
	int res=1;
	for(int i=1;i<=n;i++)
	{
		res+=need(i);
		if(!TA.fa[i])continue;
		if(need(TA.fa[i])&&!need(i))
			return INF;
	}
	G.clear();
	for(int i=1;i<=n;i++)
	{
		if(TA.fa[i]){
			if(need(i)&&need(TA.fa[i]))
				G.build(i,TA.fa[i]);
		}
		if(TB.fa[i]){
			if(need(i)&&need(TB.fa[i]))
				G.build(TB.fa[i],i);
		}
	}
	if(G.check())return res;
	return INF;
}
void solve()
{
	scanf("%d",&n);
	TA.clear();TB.clear();
	for(int i=1;i<=n;i++)Deg[i]=0;
	for(int i=1;i<n;i++)
	{
		scanf("%d %d",&U[i],&V[i]);
		Deg[U[i]]++;Deg[V[i]]++;
		TA.adde(U[i],V[i]);
	}
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d %d",&u,&v);
		TB.adde(u,v);
	}
	TA.dfs(1);TB.dfs(1);
	bool flag=false;
	for(int i=1;i<=n;i++)
		if(need(i))flag=true;
	if(!flag){
		printf("0\n");
		return ;
	}
	int ans=INF;
	for(int i=1;i<=n;i++)
	{
		if(Deg[i]!=1)continue;
		for(int j=1;j<=n;j++)
			if(i!=j)ans=min(ans,work(i,j));
	}
	if(ans>n)printf("-1\n");
	else printf("%d\n",ans);
	return ;
}
int main()
{
	int t;scanf("%d",&t);
	while(t--)
		solve();
	return 0;
}

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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main(){
  char a,b;
  cin >> a >> b;
  
  if(a == b){
    printf("H\n");
  }
  else printf("D\n");
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final int N = sc.nextInt();
        final long[] A = new long[N];
        
        A[0] = sc.nextLong();
        long prevSum = 0;
        long total = 0;
        final long MOD = 1_000_000_007;
        
        for (int i = 1; i < N; i++) {
            A[i] = sc.nextLong();
            
            prevSum += A[i - 1];
            prevSum %= MOD;
            
            total += prevSum * A[i];
            total %= MOD;
        }
        
        System.out.println(total);
    }
}


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

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

int kaijo(int p,int q){
  if(p==1) return q;
  else return kaijo(p-1,p*q);
}

int main(){
  int N;
  cin>>N;
  vector<int> x(N),y(N);
  rep(i,N) cin>>x.at(i)>>y.at(i);
  long dis;
  double ans=0;
  rep(i,N-1){
    for(int j=i+1;j<N;j++){
      dis=pow(abs(x.at(i)-x.at(j)),2)+pow(abs(y.at(i)-y.at(j)),2);
      ans+=double(sqrt(dis));
    }
  }
  cout<<fixed<<setprecision(12)<<ans*2/N<<endl;
}

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

bool isfav(string s){
    for (int i=0; i < s.size() ; i++){
      if(i%2){
        if (s.at(i)=='R'){
             return false;
              break;
        }
      }else{
         if (s.at(i)=='L'){
              return false;
              break;
         }
      }
    }
    return true;
}


int main() {
  string S;
  cin >> S;
  if (isfav(S)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

int main() {
		string S, T;
		cin >> S;
		cin >> T;
		int counter = 0;
		for(int i = 0; i < 3; ++i){
			if(S[i] == T[i]){
					counter += 1;
			}
		}
		cout << counter << endl;
}
		


Measured memory_bytes: 256
import math
import sys
sys.setrecursionlimit(10 ** 4)
N, K = map(int, input().split())
R = N - K

if R == 0: #赤いボールが無い時
    print (1)
    for _ in range(1, K):
        print (0)
    exit()

if K == 1: #青いボールが1つのとき
    print (R+1)
    exit()

K_1 = math.factorial(K-1)
R_1 = math.factorial(R+1)
# print (K_1, R_1)
for i in range(1, K+1): #K回答えを出力
    if i > R+1:
        print (0)
        continue
    if i == 1:
        print (R + 1)
        continue
    # print (K_1, R_1, math.factorial(i))
    if i == 2:
        position = R_1//(math.factorial(i) * math.factorial(R + 1- i))
        boal = K_1//(math.factorial(i-1) * math.factorial(K - i))
    if i > 2:
        position = (position * (R + 1 - (i-1))) // i
        boal = (boal * (K - (i-1)))// (i-1)
    print ((position * boal)%(7 + 10 ** 9))

Measured memory_bytes: 3444
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
using ll = long long;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

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

//動的計画法で役に立つ関数
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; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

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

vector<vector<long long> > comb(int n) {
  vector<vector<long long> > v(n + 1,vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    int N, M=0;
    cin >> N;
    VI A(N);
    VI ANS;
    REP(i,N)
    {
        cin >> A[i];
    }
    VI B(N, 0);
    REP(i,N)
    {
        int i_ = N-1-i;
        int j=i_;
        int sum_b = 0;
        while(j+i_+2 <= N)
        {
            sum_b += B[j+i_+1];
            j += i_+1;
        }

        B[i_] = (sum_b + A[i_]) % 2;
        if (B[i_] == 1) 
        {
            M++;
            ANS.pb(i_+1);
        }
    }
    
    cout << M << endl;
    if (M!=0) PRINT(ANS); cout << endl;


    return 0;
}



Measured memory_bytes: 3192
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    let n: u64 = read();
    let y: u64 = read();
    for n10000 in 0..n + 1 {
        for n5000 in 0..n + 1 {
            if n < n10000 + n5000 {
                break;
            }
            let n1000 = n - n10000 - n5000;
            let p = n10000 * 10000 + n5000 * 5000 + n1000 * 1000;
            if p == y {
                println!("{} {} {}", n10000, n5000, n1000);
                return;
            }
        }
    }
    println!("-1 -1 -1 ");
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstring>
//#include<bits/stdc++.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#define  si(a)       scanf("%d",&a)
#define  sl(a)       scanf("%lld",&a)
#define  sii(a,b)    scanf("%d%d",&a,&b)
#define  sll(a,b)    scanf("%lld%lld",&a,&b)
#define  queues      priority_queue
#define mod  10000007
#define mem(a)  memset(a,0,sizeof(a));
#define def(a) ((a)&(-a))
#define fi  first
#define se  second
#define mp  make_pair
#define  pb push_back
#define mem(a,b) memset(a,b,sizeof(a));
typedef long long ll;
const ll maxn=5000006;
//priority_queue<ll,vector<ll >,greater<ll > >q;
const ll INF=0x3f3f3f3f;
//const double E=exp(1);
//const double PI=acos(-1);
using namespace std;
//__builtin_popcount
//priority_queue

int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
ll kc(ll a,ll b){ll c=1;while(b){if(b&1)c=(c*a)%mod;a=(a*a)%mod;b>>=1;}return c;}
bool cmp(double x,double y){return x>y;}
int read(){int x=0,f=1;char s=getchar();for(; s>'9'||s<'0'; s=getchar()) if(s=='-') f=-1;for(; s>='0'&&s<='9'; s=getchar()) x=x*10+s-'0';return x*f;}
vector<int>q;
int n,k;
int a[maxn];
int b[maxn];
int dd(int m)
{  int sum[503],sum1[503];

mem(sum,0);mem(sum1,0);
    for(int i=1;i<=n;i++)
        b[i]=a[i]%m;
    sort(b+1,b+1+n);
    for(int i=1;i<=n;i++)
        sum[i]=sum[i-1]+b[i];
    for(int i=n;i>=1;i--)
    sum1[i]=sum1[i+1]+(m-b[i]);
    for(int i=1;i<=n;i++)
        if(sum[i]==sum1[i+1]&&sum[i]<=k)return 1;
    return 0;
}
int main()
{ int ant=0;
     ios::sync_with_stdio(false);
     cin>>n>>k;
    for(int i=1;i<=n;i++)
         cin>>a[i],ant+=a[i];
         for(int i=1;i*i<=ant;i++)
             if(ant%i==0)
         {
             q.pb(i);
             if(i*i!=ant)q.pb(ant/i);
         }
         int M=0;
         for(int i:q)
         {
             if(dd(i))
                M=max(i,M);
         }
         cout<<M;
}


Measured memory_bytes: 2304
#include <stdio.h>

#define abs(x)  (  (x)>=0 ? (x) : ( (x)*-1)  )

int main(){

    int ant[5], i, j, k, ans = 0;

    for (i=0; i<5; i++){
        scanf("%d", &ant[i]);
    }
    scanf("%d", &k);

    for (i=0; i<5; i++){
        for (j=0; j<5; j++){
            if ((abs(ant[i]-ant[j]) > k) && (i!=j)){
                ans = 1;
            }
        }
    }

    if (ans == 1){
        printf(":(");
    }else{
        printf("Yay!");
    }

    return 0;
}

Measured memory_bytes: 128