akhauriyash/Code-Regression huggingface dataset:
/*
 * short          2^15-1 ~ 3e4
 * int, long x86  2^31-1 ~ 2e9
 * long long      2^63-1 ~ 9e18
 */
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define fr(a, b) for (int a = 0; a < b; ++a)
using namespace std; typedef long long ll; const int inf = numeric_limits<int>::max(); void print() {cerr << endl;}
template<typename T, typename... Ts> void print(T&&a, Ts&&...etc) {cerr << a << ' '; print(etc...);}
template<typename T, typename U> ostream& operator<<(ostream& s, const pair<T,U>&p) {s << "<" << p.x << ", " << p.y << ">"; return s;} // ver. 2020-02-17
template<typename T> ostream& operator<<(ostream& s, const vector<T>&v) {s << "["; for (auto &x : v) s << x << ", "; if (!v.empty()) s << "\b\b"; s << "]"; return s;}
struct io{io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}}io;

int n;
vector<vector<int>> g;
vector<ll> dp;
vector<ll> sz;
vector<ll> ans;
const int N = 200001;
const ll mod = 1000000007;
ll f[N+1];

ll poww(ll a, ll n) {
    if (n == 0) return 1;
    if (n % 2) {
        return (a * poww(a, n - 1)) % mod;
    }
    ll a2 = poww(a, n/2);
    return (a2 * a2) % mod;
}

ll inv(ll a) {return poww(a, mod - 2);}

void dfs_init(int v, int parent) {
    sz[v] = 1;
    dp[v] = 1;
    ll mul = 1;
    ll sum = 0;
    ll den = 1;
    // dp_i = (Σ sz_i)! * Π( dp_i / (sz_i)! )
    for (int u : g[v]) {
        if (u != parent) {
            dfs_init(u, v);
            sz[v] = (sz[v] + sz[u]) % mod;
            sum = (sum + sz[u]) % mod;
            mul = (mul * dp[u]) % mod;
            den = (den * f[sz[u]]) % mod;
        }
    }
    dp[v] = ((mul * f[sum]) % mod) * inv(den) % mod;
}

void reroot(int r, int v) {
    // update DP when the root moves from r to v
    // r and v must be neighbours
    if (r == -1) return;

    // new size of r-subtree:
    sz[r] = n - sz[v];

    // remove v-subtree from r:
    dp[r] *= inv((f[n-1] * dp[v]) % mod);
    dp[r] %= mod;
    dp[r] *= (f[n-1-sz[v]] * f[sz[v]]) % mod;
    dp[r] %= mod;

    // add r-subtree to v:
    dp[v] *= (f[n-1] * dp[r]) % mod;
    dp[v] %= mod;
    dp[v] *= inv((f[sz[v]-1] * f[sz[r]]) % mod);
    dp[v] %= mod;

    // v is the new root:
    sz[v] = n;
}

void dfs_reroot(int v, int parent) {
    ans[v] = dp[v];
    for (int u : g[v]) {
        if (u != parent) {
            reroot(v, u);
            dfs_reroot(u, v);
            reroot(u, v);
        }
    }
}

int main() {
    f[0] = 1;
    for (ll i = 1; i <= N; ++i) {
        f[i] = f[i-1] * i % mod;
    }

    cin >> n;
    g = vector<vector<int>>(n);
    dp.assign(n, 1);
    sz.assign(n, 0);
    ans.assign(n, 0);

    int u, v;
    fr(i, n-1) {
        cin >> u >> v;
        u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }

    dfs_init(0, -1);

    dfs_reroot(0, -1);

    fr(k, n) {
        cout << ans[k] << '\n';
    }
}


Measured memory_bytes: 20212
while True :
    a, op, b = map(str, raw_input().split(" "))
    a = int(a)
    b = int(b)
    if (op == "?") :
        break
    elif (op == "+") :
        print("%d" % (a+b))
    elif (op == "-") :
        print("%d" % (a-b))
    elif (op == "*") :
        print("%d" % (a*b))
    elif (op == "/") :
        print("%d" % (a/b))

Measured memory_bytes: 6444
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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

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

	ll n,k; cin >> n >> k;

	vector<ll> a(n), arev(n);
	rep(i,n) {cin >> a[i]; }
	sort(all(a));
	rep(i,n) arev[i] = a[n-i-1];

	auto check = [&](ll mid) {
		auto comp = [&mid](ll a, ll b) { return a * b <= mid;};
		ll cnt = 0;
		rep(i, n) {
		   if (a[i] < 0) cnt += lower_bound(all(arev), a[i], comp) - arev.begin();
			 else cnt += lower_bound(all(a), a[i], comp) - a.begin();

			 if (a[i]*a[i] <= mid) cnt--;

		}

		cnt >>= 1;

		return cnt < k;
	};

	ll ng = -1e18, ok = 1e18+1;
	while (ng + 1 < ok) {
		ll mid = (ng + ok) / 2, cnt = 0;

		if (check(mid)) ng = mid;
		else ok = mid;
	}
	cout << ok << endl;
}



Measured memory_bytes: 6348
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll n;
        cin >> n;
        ll x = (-1 + sqrt(1 + 8 * n)) / 2;
        if(x * (x + 1) == 2 * n){

        }
        else{
            x++;
        }
        cout << x;
    }
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int mod=1000000007;

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n,x=0;
  cin>>n;
  vector<ll> d(n,0);
  for(ll i=0; i<n; i++){
    cin>>d[i];
    x=x^d[i];
  }
  for(ll i=0; i<n; i++){
    ll a=x^d[i];
    cout<<a<<" ";
  }
    return 0;
}

Measured memory_bytes: 4712
#include <bits/stdc++.h>
using namespace std;
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;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

ll pow_mod(ll n, ll k, ll mod) {
    if(k == 0) {
        return 1;
    } else if(k % 2 == 1) {
        return pow_mod(n, k - 1, mod) * n % mod;
    } else {
        ll t = pow_mod(n, k / 2, mod);
        return t * t % mod;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int mod = 2019;
    string s;
    cin >> s;
    int n = s.size();
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        a[i] = s[i] - '0';
    }
    reverse(ALL(a));
    vector<int> sum(n + 1, 0);
    map<ll, ll> mp;
    mp[0]++;
    for(int i = 0; i < n; i++) {
        sum[i + 1] = sum[i] + a[i] * pow_mod(10, i, mod) % mod;
        sum[i + 1] %= mod;
        mp[sum[i + 1]]++;
    }
    ll ans = 0;
    for(auto p : mp) {
        ans += p.second * (p.second - 1) / 2;
    }
    cout << ans << endl;
}

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

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

    if (s[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }

    int c = 0;
    for (int i = 2; i < s.size()-1; i++) {
        if (s[i] == 'C') {
            c++;
        }
    }
    if (c != 1) {
        cout << "WA" << endl;
        return 0;
    }

    for (int i = 0; i < s.size(); i++) {
        if (s[i] != 'A' && s[i] != 'C' && ('a' > s[i] || 'z' < s[i])) {
            cout << "WA" << endl;
            return 0;
        }
    }

    cout << "AC" << endl;


    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int i, j, n, p;
  int x[100], y[100];
  double sum, d;
   
  cin >> n;
 
  for( i = 0; i < n; i++ ) cin >> x[i];
  for( i = 0; i < n; i++ ) cin >> y[i];
 
  // when 1 <= p <= 3
  for( p = 1; p <= 3; p++ ){
    sum = 0;
    for( i = 0; i < n; i++ ){
      sum += pow( fabs( x[i] - y[i] ), p );
    }
    printf("%lf\n", pow( sum, 1.0/p ) );
  }
 
  // when p is unlimited
  for( i = 0; i < n; i++ )
    d = d < fabs( x[i] - y[i] ) ? fabs( x[i] - y[i] ) : d;  
  printf("%lf\n", d);
   
  return 0;
}

Measured memory_bytes: 3328
<?php

$stdin = preg_split('/ /', trim(fgets(STDIN)));
$r = intval(array_shift($stdin));
$c = intval(array_shift($stdin));
$matrix = array();
for ($i = 0; $i < $c+1; $i++) {
    $matrix[$r][$i] = 0;
}

for ($i = 0; $i < $r; $i++) {
    $matrix[$i] = preg_split('/ /', trim(fgets(STDIN)));
    $matrix[$i][] = array_sum($matrix[$i]);
}

for ($i = 0; $i < $c+1; $i++ ) {
    for ($j = 0; $j < $r; $j++) {
        $matrix[$r][$i] += $matrix[$j][$i];
    }
}

for ($i = 0; $i < $r+1; $i++) {
    for ($j = 0; $j < $c+1; $j++) {
        print($matrix[$i][$j]);
        if ($j != $c) {
            print(' ');
        }
    }
    print("\n");
}

Measured memory_bytes: 8500
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll INF = 1145148931919810;
ll n, m, d;
int main(){
    cin >> n >> m >> d;
    if(n < d){
        cout << 0 << endl;
    }else{
        printf("%.10f\n", (double)(d ? 2 : 1) * (n - d) * (m - 1) / (n * n));
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
const ll mod=1e9+7;
ll f[N],n,m,A,B;
ll powmod(ll x,ll n){
    ll s=1;
    while(n){
        if(n&1)
            s=(s*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return s;
}
ll C(ll n,ll m){
    ll a=f[n];
    ll b=(f[m]*f[n-m])%mod;
    return (a*powmod(b,mod-2))%mod;
}
int main()
{
    f[0]=1;
    for(ll i=1;i<N;i++)
        f[i]=(f[i-1]*i)%mod;
    while(cin>>n>>m>>A>>B){
        ll res=0;
        for(ll i=B+1;i<=m;i++){
            ll tmp=(C(i-1+n-A-1,n-A-1)*C(m-i+A-1,m-i))%mod;
            res=(res+tmp)%mod;
        }
        cout<<res<<endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<cstdlib>
#include<list>
#include<set>
#include<numeric>

#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int field[1010][1010][3];

int main()
{
	int M, N;  cin >> M >> N;
	int K; cin >> K;
	string str = "JOI";

	for (int i = 1; i <= M; i++) {
		for (int j = 1; j <= N; j++) {
			char c;
			cin >> c;
			for (int k = 0; k < 3; k++)
				field[i][j][k] = field[i - 1][j][k] + field[i][j - 1][k] - field[i - 1][j - 1][k];
			field[i][j][str.find(c)]++;
		}
	}
	for (int i = 0; i < K; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		for (int j = 0; j < 3; j++) {
			cout << field[c][d][j] + field[a - 1][b - 1][j] - field[a - 1][d][j] - field[c][b - 1][j];
			if (j != 2)cout << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 14876
#include<iostream>
#include<string>
#include<math.h>
using namespace std;


int main(){
    int N,A,B;
    cin>>A>>B;

    int sub=B-A;
    int sum=0;

    for(int i=sub;i>0;i--){
        sum=sum+i;
    }
    cout<<sum-B;



    return 0;
}

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

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

LL N, H;
V<PLL> v;

int main(){
    INIT;
    cin >> N; cin >> H;
    REP(i,N) {
        int a, b; cin >> a >> b;
        v.push_back(PII(b,a));
    }

    std::sort(ALL(v));

    LL max_ai = v[0].second;
    LL ai_idx = 0;
    for(int i = 1; i < N; i++) {
        if(max_ai < v[i].second) {
            ai_idx = i; max_ai = v[i].second;
        }
    }

    LL cnt = 0;
    for(int i = N-1; i >= 0; i--) {
        if(H <= 0) break;
        if(max_ai < v[i].first) {
            H -= v[i].first;
            cnt++;
        }
    }

    if(0 < H) cnt += (H+max_ai-1)/max_ai;

    cout << cnt << "\n";
}

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

int main() {
  int a, b;
  char op;
  while (true) {
    cin >> a >> op >> b;
    switch (op) {
      case '+':
        cout << a + b << endl;
        break;
      case '-':
        cout << a - b << endl;
        break;
      case '*':
        cout << a * b << endl;
        break;
      case '/':
        cout << a / b << endl;
        break;
      default:
        return 0;
    }
  }
}



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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
void debug(vector<vector<ll>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
void debug(vector<ll>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
//m.emplace(x,0).fi->se++;

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n,k;cin>>n>>k;
  vector<ll>a(n);
  ll sumbuf=0;
  rep(i,0,n){
    cin>>a[i];
    sumbuf+=a[i];
  }
  set<ll,greater<ll>>s;
  for(ll i=1;i*i<=sumbuf;i++){
    if(sumbuf%i==0){
      s.insert(i);
      s.insert(sumbuf/i);
    }
  }
  for(auto z:s){
    vector<ll>p;
    rep(i,0,n){
      p.push_back(a[i]%z);
    }
    sort(ALL(p));
    ll l=0,r=p.size()-1;
    ll countbuf=0;
    while(l!=r){
      if(p[l]>z-p[r]){
        p[l]-=z-p[r];
        countbuf+=z-p[r];
        r--;
      }
      else{
        p[r]+=p[l];
        countbuf+=p[l];
        l++;
      }
      //cout<<countbuf spa l spa r<<endl;
    }
    //cout<<z spa countbuf<<endl;
    if(countbuf<=k){
      cout<<z<<endl;
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

		int length = sc.nextInt();
		int cnt = 0;

		for(int i = 1; i <= length;i++) {
			cnt += (sc.nextInt() != i) ? 1 : 0;
			if(cnt >= 3) {
				break;
			}
		}

		System.out.println(cnt <= 2 ? "YES" : "NO");
	}
}


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

int fib(int *,int);

int main()
{
  int n,i,F[45];

  scanf("%d",&n);
  if(n<0 || n>44) exit(1);
  for(i=0;i<45;i++) F[i] = -1; //数を入れたかどうかを関数の中で判断するのに使う
  printf("%d\n",fib(F,n));
  

  return 0;
}

int fib(int *F,int n)
{
  if(n == 0||n == 1){
    F[n] = 1;
    return F[n];//n=0,1のときは1
  }
    if(F[n] != -1) return F[n]; //数が入ってたらそれがn項の数だから返す
    return F[n] = fib(F,n-1) + fib(F,n-2); //数が入ってなかったら再起に呼び出す
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int a,b,c;
    int n;
    cin >> n;
    vector<int> l(n);
    cin >> a >> b >> c;
    rep(i,n) cin >> l[i];
    int ans = inf;
    for(int bit=0; bit<(1<<(n*2)); bit++){
        //bit2桁で表す、00未使用、01A、10B、11C
        int mp = 0;
        int A=0,B=0,C=0;
        for(int keta = 0; keta<n; keta++){
            if(((bit >> (keta*2))&0b11)==0b01) {A += l[keta]; mp += 10;}
            if(((bit >> (keta*2))&0b11)==0b10) {B += l[keta]; mp += 10;}
            if(((bit >> (keta*2))&0b11)==0b11) {C += l[keta]; mp += 10;}
        }
        //cout << "A:"<<A<<"B:"<<B<<"C:"<<C<<endl;
        mp += abs(A-a) + abs(B-b) + abs(C-c) - 30;
        if(A == 0 || B == 0 || C == 0) mp = inf;
        ans = min(ans,mp);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const S = args[0][0]
	const N = S.length
	let odd = true
	let even = true

	for (let i = 0; i < N; i++) {
		if (i % 2 === 0) {
			if (S[i] === 'R') {
				//
			} else if (S[i] === 'U') {
				//
			} else if (S[i] === 'D') {
				//
			} else {
				odd = false
			}
		} else {
			if (S[i] === 'L') {
				//
			} else if (S[i] === 'U') {
				//
			} else if (S[i] === 'D') {
				//
			} else {
				even = false
			}
		}
	}

	if (odd && even) console.log('Yes')
	else console.log('No')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 11468
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll int,ll int>
#define pb push_back
#define sbit __builtin_popcount
#define vec vector <int>
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define bg begin()
#define en end()
#define endl "\n"
#define ff first
#define ss second
#define all(x) x.bg,x.en
#define sz(a) (int)a.size()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define sp(x) setprecision(x)
#define fill(a,b) memset(a,b,sizeof(a))
#define fr(i,n) for(int i=0;i<n;i++)
#define rp(i,a,b) for(int i=a;i<b;i++)
#define rr(i,a,b) for(int i=a;i>=b;i--)
#define ft(it,x) for(auto it : x)
#define dbg(x) cerr<<#x<<" "<<x<<endl;
#define dbga(arr,n) cerr<<#arr<<": "; rep(tt,0,n)cerr<<arr[tt]<<" "; cerr<<endl;
#define mapi map<int,int>
#define mapl map<ll int,ll int>
#define val_at(x) find_by_order(x)
#define idx_of(x) order_of_key(x)
#define scni(x) scanf("%d",&x)
#define prt(x) printf("%d\n",x)
#define test(t) int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> myset;
const int mod=1e9+7;
const int mex=1e6+1;
inline ll power(ll a,ll b)
{
    ll ans=1,temp=a;
    while(b!=0)
    {
        if(b&1)
        ans=ans*temp;
        ans=ans%mod;
        temp=temp*temp;
        temp=temp%mod;
        b/=2;
    }
    return ans;
}
int pr[mex];
vec prime;
inline void seive()
{
    rp(i,2,mex) pr[i]=1;
    for(int i=2;i*i<mex;i++)
    {
        if(pr[i])
        for(int j=i*i;j<mex;j+=i)
        pr[j]=0;
    }
    vec prime;
    rp(i,2,mex)
    {
        if(pr[i]) prime.pb(i);
    }
}
ll int xx,xy,d1;
void exeu(ll int a1,ll int b1)
{
    if(b1==0)
    {
        xx=1;
        xy=0;
        d1=a1;
    }
    else
    {
        exeu(b1,a1%b1);
        ll int temp=xx;
        xx=xy;
        xy=temp-(a1/b1)*xy;
    }
}
ll int modinv(ll int A,ll int M)
{
    exeu(A,M);
    return (xx%M+M)%M;
}
ll gcd(ll int a,ll int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
ll lcm(ll int arr[], ll int n, ll int m) 
{ 
    ll ans = arr[0]; 
    for (int i = 1; i < n; i++){
        ans = (((arr[i] * ans))/(gcd(arr[i], ans)));
        if(ans>m) return -1;
    }
    return ans; 
} 
int main()
{
    fast
    ll int n,m;
    cin>>n>>m;
    ll int a[n];
    fr(i,n){
      cin>>a[i];
      a[i]/=2;
    } 
    ll int lm=lcm(a,n,m);
    fr(i,n)
    {
        int x=lm/a[i];
        if(x%2==0)
        {
            lm=-1;
            break;
        }
    }
    if(lm==-1)
    {
        cout<<"0\n";
        return 0;
    }
    ll int x=m/lm;
    ll cnt=(x+1)/2; 
    cout<<cnt;
    return 0;
}

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


void solve(long long N){
    ll ans = 0;
    map<pair<char, char>, int> mp;
    for(int i = 1;i <= N;i++){
        string s = to_string(i);
        mp[make_pair(s.front(), s.back())]++;
    }
    for(int i = 0;i <= N;i++){
        string s = to_string(i);
        ans += mp[make_pair(s.back(), s.front())];
    }
    cout<<ans<<endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int main(){
	int n;
	while(cin >> n, n){
		int a[5001];
		int ans = -100000;
		for(int i = 0 ; i < n ; i++){
			cin >> a[i];
			if(i){
				a[i] = max(a[i], a[i-1] + a[i]);	
			}
			ans = max(ans, a[i]);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>

// output
#define SPBR(w, n) std::cout << (w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define RFOR(i, a, n) for (int i = (n)-1; i >= (a); --i)
#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 IN(a, x, b) (a <= x && x < b)
#define OUT(a, x, b) (x < a || b <= x)
template <class T> inline T chmax(T &a, const T b) {
  return a = (a < b) ? b : a;
}
template <class T> inline T chmin(T &a, const T b) {
  return a = (a > b) ? b : a;
}

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;

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

  vector<pair<int, int>> A(N);
  REP(i, N) cin >> A[i].first >> A[i].second;

  vector<int> dp(H+1, INF);
  dp[H] = 0;
  RREP(i, H+1){
    REP(j, N){
      chmin(dp[max(0ll, i-A[j].first)], dp[i]+A[j].second);
    }
  }

  cout << dp[0] << endl;

  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod 1000000007
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
int x[100];
vector<int> v;
stack<int> s;
signed main(){
	int n;
	cin>>n;
	f(i,n){
		cin>>x[i];
		v.push_back(x[i]);
	}
	f(j,n){
		for(int i=v.size()-1;i>=0;i--){
			if(i==v[i]-1){
				s.push(v[i]);
				v.erase(v.begin()+i);
				goto loop;
			}
		}
		puts("-1");
		return 0;
		loop:;
	}
	while(s.size()){
		cout<<s.top()<<endl;
		s.pop();
	}
    return 0;
}


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

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

Measured memory_bytes: 256
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

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

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    string s;
    cin >> s;
    bool ans = (s[2]==s[3]) && (s[4]==s[5]);
    print(ans ?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

A=[list(map(int,input().split())) for i in range(3)]
N=int(input())
B=[int(input()) for i in range(N)]

ANS=[[0]*3 for i in range(3)]

B=set(B)

for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            ANS[i][j]=1

SCORE=0
for i in range(3):
    if sum(ANS[i])==3:
        SCORE=1

for i in range(3):
    X=0
    for j in range(3):
        X+=ANS[j][i]
    if X==3:
        SCORE=1

if ANS[0][0]==1 and ANS[1][1]==1 and ANS[2][2]==1:
    SCORE=1

if ANS[0][2]==1 and ANS[1][1]==1 and ANS[2][0]==1:
    SCORE=1

if SCORE==1:
    print("Yes")
else:
    print("No")
        


Measured memory_bytes: 3064
n, k = map(int, input().split())
A = list(map(int, input().split()))

for i in range(min(50, k)):
    DP = [0] * (n+1)
    for j in range(n):
        light = A[j]
        DP[max(0, j-light)] += 1
        DP[min(n, j+light+1)] -= 1

    for j in range(1, n):
        DP[j] += DP[j-1]

    A = DP[:-1]

print(*A)

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

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

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;
using vvvi=vector<vvi>;

int solve(const string& s,int l,int r,int x,vvvi& memo)
{
	if(l>=r) return 0;
	int& res=memo[l][r][x];
	if(res==-1){
		assert(l<r);
		if(r-l==1)
			chmax(res,1);
		else{
			chmax(res,solve(s,l,r-1,x,memo));
			chmax(res,solve(s,l+1,r,x,memo));
			if(s[l]==s[r-1])
				chmax(res,solve(s,l+1,r-1,x,memo)+2);
			if(x)
				chmax(res,solve(s,l+1,r-1,x-1,memo)+2);
		}
	}
	return res;
}

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(string s;cin>>s;){
		int k; cin>>k;
		int n=s.size();
		vvvi memo(n,vvi(n+1,vi(k+1,-1)));
		cout<<solve(s,0,n,k,memo)<<endl;
	}
}


Measured memory_bytes: 109952
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll INF = 5e15;
ll N, P;
int main(){
    cin >> N >> P;
    ll ans = 1;
    if(N == 1){
        cout << P << endl;
        return 0;
    }
    for(ll i = 2; i * i <= P; i++){
        ll cnt = 0;
        ll cpy = P;
        while(cpy % i == 0){
            cpy /= i;
            cnt++;
        }
        if(cnt >= N) ans = i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

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

static const double eps = 1e-8;

int main(){

	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;

		double areaA=0,areaB=0;
		int remain=360;
		for(int i=0;i<n-1;i++){
			double rad;
			int angle;
			scanf("%d",&angle);
			remain-=angle;
			rad = (double)angle / 180.0 * M_PI;
			areaA += 0.5*sin(rad);
		}

		areaA += 0.5*sin((double)remain / 180.0 * M_PI);

		remain=360;
		scanf("%d",&n);
		for(int i=0;i<n-1;i++){
			double rad;
			int angle;
			scanf("%d",&angle);
			remain-=angle;
			rad = (double)angle / 180.0 * M_PI;
			areaB += 0.5*sin(rad);
		}

		areaB += 0.5*sin((double)remain / 180.0 * M_PI);

		printf("%d\n",abs(areaA - areaB) < eps ? 0 :
			areaA > areaB ? 1 : 2);
	}
}

Measured memory_bytes: 0
import java.io.*;
import java.util.*;
public class Main {
    static long dfs(int[][] met, int m, int wmask, long[][] map) {
        if(m >= met.length) {
            return 1;
        }
        // String key = m + "" + wmask;
        if(map[m][wmask] != -1){
            // System.out.println("Key found " + map.get(key));
            return map[m][wmask];
            
        }
            
        int[] wo = met[m];
        long sum = 0;
        for(int w = 0; w < met.length; w++) {
            if(met[m][w] == 1 && (wmask & 1 << w) == 0) {
                sum = (sum + dfs(met, m+1, wmask | (1 << w), map))%MOD;
            }
        }
        
        map[m][wmask] = sum;
        return sum;
    }
    static long MOD = 1000*1000*1000 + 7;
    public static void main(String args[]) {
        int n = 0;
        
        int[][] met = null;
        try (Scanner scanner = new Scanner(System.in)) {
            n = scanner.nextInt();
            met = new int[n][n];
            for(int i = 0; i < n ;i++) {
                for(int j = 0; j < n ;j++) {
                    met[i][j] = scanner.nextInt();
                }
            }
        }
        
        long[][] map = new long[n][1<<n];
        for(long[] m : map)
            Arrays.fill(m, -1);
        // HashMap<String, Long> map = new HashMap();
        long ret = dfs(met, 0, 0, map);
        
        // System.out.println(map);
        System.out.println(ret);
        
    }
    
}

Measured memory_bytes: 369748
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
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++)

using LL = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const int c[10] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int N = 200;
string w = "0123456789";
int n, m, a[10], b;
string dp[N];

void update(string &s, string t) {
	if (t.length() > s.length() || t.length() == s.length() && t > s)
		s = t;
}

string dfs(int n) {
	if (n == 0 || dp[n] != "")
		return dp[n];
	string &s = dp[n];
	FOR(i, 1, 9) if (a[i] && n >= c[i]) {
		const string tmp = dfs(n - c[i]);
		if (n > c[i] && tmp == "")
			continue;
		update(s, w[i] + tmp);
		update(s, tmp + w[i]);
	}
	return s;
}

int main() {
	cin >> n >> m;
	REP(i, m) {int x; cin >> x; a[x] = 1; }
	FOR(i, 1, 9) if (a[i] && (b == 0 || c[b] >= c[i])) b = i;
	string t = "";
	while (n >= N) n -= c[b], t += (char)('0' + b);
	string tmp = dfs(n);
	string ans = tmp + t;
	update(ans, t + tmp);
	tmp = tmp + t;
	sort(tmp.begin(), tmp.end());
	reverse(tmp.begin(), tmp.end());
	update(ans, tmp);
	cout << ans << endl;
	// cout << b << " " << c[b] << endl;
	// REP(i, 10) cout << i << " " << a[i] << " " << c[i] << endl;
	// FOR(i, 1, n) cout << i << ":" << dp[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
// Recursive function to return gcd of a and b
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

// Driver program to test above function
int main()
{
    long int a,b;
    cin>>a>>b;
     long long x=a*b;
     cout<<x/(gcd(a,b))<<endl;
    return 0;
}

Measured memory_bytes: 256
import qualified Data.IntMap as M

main :: IO ()
main = do
    [_, m] <- readInts
    as <- readInts
    print $ solve m as

readInts :: IO [Int]
readInts = map read . words <$> getLine

solve :: Int -> [Int] -> Int
solve m =  M.foldr (\x y -> (x * (x - 1) `div` 2) + y) 0
     . foldr (M.alter $ return . maybe 1 succ)  M.empty
     . map (`mod` m)
     . scanl (+) 0


Measured memory_bytes: 38268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S, LS="", SR=""; cin >> S;
    ll Q; cin >> Q;
    bool flag = true;
    for(int i = 0; i < Q; i++){
        int T; cin >> T;
        if(T == 1){
            if(flag) flag = false;
            else flag = true;
        }
        else if (T == 2){
            int f;
            char ch;
            cin >> f >> ch;
            if(f == 1){
                if(flag){
                    LS.push_back(ch);
                    //S = ch+S;
                }
                else {
                    SR.push_back(ch);

                    //S += ch;
                }
            }
            else{
                if(flag) {
                    //S += ch;
                    SR.push_back(ch);
                }
                else {
                    LS.push_back(ch);
                    //S = ch+S;
                }
            }
        }
    }
    reverse(LS.begin(), LS.end());
    S = LS+S+SR;
    if(flag) {
        cout << S << endl;
    }
    else {
        reverse(S.begin(), S.end());
        cout << S << endl;
    }
}

Measured memory_bytes: 1200
//Abu Sayeb Rayhan
//Comilla University
//14 March,2020

#include<bits/stdc++.h>
#define lli long long int
#define pi 2*acos(0.0)
#define spc " "
#define mod 100000009
#define forn(a,n) for(int i=a;i<n;i++)
#define sayeb ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define boss cout<<"sayeb"<<endl
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define maxi 10000000000000000
int ar[10000000];
using namespace std;

void solve()
{
    lli n,k;
    cin>>n>>k;
    if(n==1||k==1)
    {
        cout<<"1"<<endl;
        return ;
    }
    lli p=n*k;
    if(p%2!=0)
        cout<<p/2+1<<endl;
    else
        cout<<p/2<<endl;

}

int main()
{
	sayeb;
    int t;
    //cin>>t;while(t--)
    solve();
    return 0;
}




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

using namespace std;

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

int a, b;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> a >> b;
    if ( abs(a-b) > 1) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vector<T>>;
using vl = vector<ll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//--------------------------------------------------------------------------------//

int main() {
    init();
    string t = "CODEFESTIVAL2016";
    string s;
    cin >> s;
    ll ans = 0;
    rep(i, (ll)t.size()) {
        if (t[i] != s[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::Read;
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();
    let c: usize = iterator.next().unwrap().parse().unwrap();
    let d: usize = iterator.next().unwrap().parse().unwrap();

    let ans = min(a, b) + min(c, d);
    return ans.to_string();
}


Measured memory_bytes: 2152
//If you are reading this then you are at wrong place.
#include<bits/stdc++.h>
#define mod 1000000007
#define lli long long int
using namespace std;
bool prime [1000001];
void debug(lli a){cout<<a<<endl;}
lli sieve(lli a){memset(prime,true,sizeof(prime));lli p,i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli find_max(lli __a,lli __b){return __a^((__a^__b) & -(__a<__b));}
lli add(lli __a,lli __b,lli MOD){lli x = (__a+__b)%MOD; return x; }
lli mul(lli a,lli b,lli MOD){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b,lli MOD){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b,lli MOD){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
vector<int>answer[100001];
int main()
{
	//ifstream cin("testcase.txt");
	//ofstream cout("output.txt");	
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);	
	cout.precision(20);
	lli t,i,j;
	//cin>>t;
	//memset(dp, -1, sizeof dp);
	t=1;
	lli counter1=0;
	while(t--)
	{
		counter1++;
		int n,m;
		cin>>n>>m;
		int x,y;
		while(m--)
		{
			cin>>x>>y;
			answer[x].push_back(y);
			answer[y].push_back(x);
		}
		for(i=1;i<=n;i++)
			cout<<answer[i].size()<<endl;
		
		//cout<<"Case #"<<counter1<<" ";
		//cout<<endl;	
	}	
}


Measured memory_bytes: 2560
package main

import "fmt"

const target = "ABC"

func main() {
	s := input()
	c := 0
	for i := 0; i <= len(s)-3; i++ {
		if target == s[i:i+3] {
			c++
		}
	}
	fmt.Println(c)
}

func input() string {
	var n int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	return s
}


Measured memory_bytes: 512
#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int n, m, dis[100009][4], inf=2e9;
vector<int> v[100009];
void BFS(int s)
{
    queue<pair<int,int> > q ;
    q.push({s,0});
    for(int i=1; i<=n; i++)
        dis[i][0]=dis[i][1]=dis[i][2]=inf;
    dis[s][0] = 0;
    while(!q.empty())
    {
        int node=q.front().first, d=q.front().second;
        q.pop();
        for(auto i : v[node])
            if(dis[i][(d+1)%3]>dis[node][d]+1)
            {
                dis[i][(d+1)%3]=dis[node][d]+1;
                q.push({i,(d+1)%3});
            }
    }
}
int main()
{
    IO
    cin>>n>>m;
    for(int i=1; i<=m; i++)
    {
        int x, y ;
        cin>>x>>y;
        v[x].push_back(y);
    }
    int s, t ;
    cin>>s>>t;
    BFS(s);
    if(dis[t][0]>=inf)
        dis[t][0]=-3;
    cout<<dis[t][0]/3;
}


Measured memory_bytes: 7296
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
const ll N = 3e3 + 1;
ll n,k;
ll arr[N][N];
bool kek[N][N];
ll a[N];
ll recurs(ll l = 0 ,ll r = n - 1){
	if(l == r){
		arr[l][r] = a[l];
		return a[l];	
	}
	if(kek[l][r])return arr[l][r];
	kek[l][r] = 1;
	arr[l][r] = max(a[l] - recurs(l + 1,r),a[r] - recurs(l,r - 1));
	return arr[l][r];
}

int main() {
	speed;
	cin >> n;
	for(int i = 0 ; i < n ; i++)
		cin >> a[i];
	recurs();
	cout << arr[0][n - 1];
}
/*
Timus : 288471KD
Atcoder : Zhabka
Codeforces : Zhabka
mail : dzhon.snoudin@mail.ru
*/



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

int f(int a)
{
    int res = 1;
    for(int i=0; i<a; i++)
    {
        res *= 2;
    }
    
    return res;
}

int main(void)
{
    int H, W, K;
    cin >> H >> W >> K;
    
    vector<vector<char>> v(H, vector<char>(W, 'a'));
    
    for(int i=0; i<H; i++)
    {
        for(int j=0; j<W; j++)
        {
            cin >> v[i][j];
        }
    }
    
    int mH = f(H);
    int mW = f(W);
    int ans = 0;
    
    for(int i=0; i<mH; i++)
    {
        bitset<6> h(i);
        for(int j=0; j<mW; j++)
        {
            bitset<6> w(j);
            
            int count = 0;
            for(int a=0; a<H; a++)
            {
                if(h[a]) continue;
                for(int b=0; b<W; b++)
                {
                    if(w[b]) continue;
                    
                    if(v[a][b] == '#') count++;
                }
            }
            
            if(count == K) ans++;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

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

int main() {
  long long x, k, d;
  cin >> x >> k >> d;
  if (x > 0 && x/d > k) cout << x-k*d << endl;
  else if (x <= 0 && (-x)/d > k) cout << abs(x+k*d) << endl;
  else if (x > 0) {
    k -= x/d;
    x -= (x/d)*d;
    if (k%2==1) cout << abs(x-d) << endl;
    else cout << x << endl;
  }
  else {
    k -= (-x)/d;
    x += ((-x)/d)*d;
    if (k%2==1) cout << x+d << endl;
    else cout << abs(x) << endl;
  }
}

Measured memory_bytes: 3588
# -*- coding: utf-8 -*-

a, b = map(int, input().split())
A = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]
if A.index(a) > A.index(b):
    print('Alice')
elif A.index(a) < A.index(b):
    print('Bob')
else:
    print('Draw')


Measured memory_bytes: 2940
#include <iostream>
#include <string>

using namespace std;

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

  int Es = 0;
  int Ws = 0;

  for(int i = 0;i<N;i++){
    if(S[i] == 'E'){
      Es++;
    }
  }

  int min_count=N;
  int tmp=0;

  for(int i = 0;i<N;i++){
    if(S[i]=='E'){
      Es--;
    }
    tmp = Es + Ws;
    if(tmp < min_count){
      min_count = tmp;
    }
    if(S[i]=='W'){
      Ws++;
    }
  }

  cout << min_count << endl;

  return 0;
}


Measured memory_bytes: 900
#iの倍数が書かれたハコの個数が偶数/奇数
N=int(input())
A = [int(i) for i in input().split()]
B = [None]*N
for i in range(N//2,N):
    B[i] = A[i]

for i in range(N//2):
    j = N//2- i #jの倍数(1-indexed)
    B[j-1] = (sum([B[k*j -1] for k in range(2,N//j+1)]) - A[j-1]) %2
ans = [k+1 for k in range(N) if B[k]]
print(len(ans))
print(*ans)

Measured memory_bytes: 93916
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD=1e9+7;
int h[100005];
int main(){
        int n;
        while(~getI(n)){
                F(i,0,n) getI(h[i]);
                h[0]--;
                bool yes=1;
                F(i,1,n) if(h[i]>h[i-1]) h[i]--;
                F(i,1,n) if(h[i]<h[i-1]) yes=0;
                printf("%s\n",yes==1?"Yes":"No");
        }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    int a,b;
    cin >> a >> b;
    cout << a*b << endl;

    return 0;
}











Measured memory_bytes: 3616
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main(){
	
	char s1[10];
	char s2[10];
	char s3[10];
	scanf("%s %s %s",s1,s2,s3);

	if(s1[0]>=97&&s1[0]<=122){
	
	s1[0]=(s1[0]-32);
	}
	
	printf("%c",s1[0]);
	
	
	if(s2[0]>=97&&s2[0]<=122)
	
		//s2[0]=(s2[0]-32);
	
	printf("%c",s2[0]-32);
	
	if(s3[0]>=97&&s3[0]<=122){
		s3[0]=(s3[0]-32);
	}
    printf("%c",s3[0]); 

	return 0;
}

Measured memory_bytes: 256