akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

int main(void)
{
    int n;
    std::cin >> n;

    std::vector<std::vector<std::pair<int, int>>> edges(n);
    for (int i = 0; i < n - 1; i++) {
        int u, v, w;
        std::cin >> u >> v >> w;
        u--;
        v--;

        edges[u].push_back(std::make_pair(v, w));
        edges[v].push_back(std::make_pair(u, w));
    }
    std::vector<int> color(n, 0);

    auto dfs = [&](auto f, int idx, int parent) -> void {
        for (auto edge : edges[idx]) {
            if (edge.first == parent) {
                continue;
            }

            color[edge.first] = (color[idx] + edge.second % 2) % 2;
            f(f, edge.first, idx);
        }
    };

    dfs(dfs, 0, -1);

    for (auto c : color) {
        std::cout << c << std::endl;
    }
}


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

int main() {
	int a,res=0,num;
	cin>>a;
	int b[200000];
	for(int i=1;i<=a;i++){
		cin>>b[i];
		if(i==1){
			num=b[i];
			res++;
		}else if(b[i]<=num){
			num=b[i];
			res++;
		}
	}
	cout<<res<<endl;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
// cin.eof() 入力個数の問題
int main() {
    int v, e, r;
    cin >> v >> e >> r;
    vector<vector<pair<int, int>>> G(v);
    rep(i, e) {
        int a, b, c;
        cin >> a >> b >> c;
        G[a].push_back(make_pair(b, c));
    }
    vector<int> ans;
    rep(i, v) {
        ans.push_back(INF);
    }
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
    ans[r] = 0;
    que.push(make_pair(ans[r], r));
map<int,bool> m;
    while (!que.empty()) {

        pair<int, int> now = que.top();
        m[now.second]=true;
        que.pop();
        //cout<<"now=="<<now.second<<endl;;
        for (auto next : G[now.second]) {
          if(m[next.first]) continue;
            ans[next.first] = min(ans[next.first], ans[now.second] + next.second);
           // cout<<" next.first=="<<next.first<<" ans=="<<ans[next.first]<<endl;
            que.push(make_pair(ans[next.first], next.first));
        }
    
    }
    rep(i, v) {
      if(ans[i]==INF){
        cout<<"INF"<<endl;
      }else
      {
        cout<<ans[i]<<endl;
      }}
      
    return 0;
}



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

using namespace std;


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

    int n;
    cin>>n;

    vector<vector<int>> mat(n, vector<int>(1, 0));
    for (int i=2; i<=n; i++){
        int curr;
        cin>>curr;
        mat[curr-1].push_back(i);
    }

    for (int i=0; i<n; i++){
        cout<<mat[i].size()-1<<endl;
    }
}

Measured memory_bytes: 15404
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'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'};
char moji2[26]={'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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    int S[n];
    REP(i,n) cin >> S[i];
    int ans = - INF;
    FOR(i,1,n){
        int l,r;
        l = 0;
        r = n-1;
        int wa = S[n-1];
        chmax(ans,wa);
        while(1){
            l += i;
            if(l == r) break;
            r -= i;
            if(l==r) break;
            if(r < i) break;
            wa += S[l];
            wa += S[r];
            chmax(ans,wa);
        }

    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	int n,k;
	cin>>n>>k;
	vector<int>a(n);
	vector<vector<int>>imos(50,vector<int>(n+2,0));
	rep(i,n){
		cin>>a[i];
		int mi=max(i-a[i],0);
		int ma=min(n-1,i+a[i]);
		imos[0][mi]++;
		imos[0][ma+1]--;
		
	}
	int cur=0;
	rep(j,min(k,50)){
		cur=0;
		bool fin=true;
		rep(i,n){
			cur+=imos[j][i];
			a[i]=cur;
			int mi=max(i-a[i],0);
			int ma=min(n-1,i+a[i]);
			imos[j+1][mi]++;
			imos[j+1][ma+1]--;
			if(a[i]!=n){
				fin=false;
			}
		}
		if(fin){
			//cout<<j<<endl;
			rep(i,n){
				cout<<n;
				if(i!=n-1){
					cout<<" ";
				}else{
					cout<<endl;
				}
			}
			return ;
		}
	}
	rep(i,n){
		cout<<a[i];
		if(i!=n-1){
			cout<<" ";
		}else{
			cout<<endl;
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 44116
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N = int(input())
S = input()

ans = 1
for i in range(1,N):
    if S[i] != S[i-1]:
        ans += 1

print(ans)


Measured memory_bytes: 77536
//BISMILLAHIR RAHMANIR RAHIM
//RHYTHM_086_NS_01
//ALAN_IS_ON....

#include <bits/stdc++.h>

#define     boost_              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define     iter_(i,n)          for (int i = 0; i < int(n); i++)
#define     for_n(i, n)         for (int i = 1; i <= int(n); i++)
#define     pb                  push_back
#define     mp                  make_pair
#define     itr                 ::iterator
#define     s_sort(s)           sort(s.begin(),s.end())
#define     n_sort(a)           sort(a,a+n)
#define     thank_you           return 0
#define     precise_impact      cout<<setprecision(10)<<fixed;

using namespace std;

typedef long long int ll;
typedef double db;
#define MOD 1000000007

ll bigmod(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll tm=bigmod(a,b/2);
    tm=(tm*tm)%MOD;
    if(b%2==1)
        tm=(tm*a)%MOD;
    return tm;

}
void solve();


int main()
{
    boost_;
    precise_impact;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Here we go...
    solve();

    thank_you;
}


void solve()
{
    ll a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;

}



Measured memory_bytes: 3608
fun abs(x:Long) :Long{
    return if (x>=0) x else -x
}

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val (t,a) = readLine()!!.split(" ").map(String::toLong)
    val h = readLine()!!.split(" ").map(String::toLong)
    var ans = arrayOf(0,10000000000000)
    for (i in 0 until n){
        val j = abs(a*1000-(t*1000-h[i]*6))
        if (j <ans[1]) {
            ans[0] = i.toLong()
            ans[1] = j
        }
    }
    print(ans[0]+1)
}

Measured memory_bytes: 35952
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <cassert>
#include <ctime>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000009
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
#define ls rt<<1
#define rs rt<<1|1
const int maxn=2e5+10;
const int N=2e5+10;
using namespace std;
int id(int l,int r){return l+r|l!=r;}
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
int n,m,k,t,q,a,b;
ll tag[maxn<<2],mi[maxn<<2],mi1[maxn<<2],mi2[maxn<<2];
void pup(int rt)
{
    mi[rt]=min(mi[ls],mi[rs]);
    mi1[rt]=min(mi1[ls],mi1[rs]);
    mi2[rt]=min(mi2[ls],mi2[rs]);
    tag[rt]=0;
}
void pdw(int rt)
{
    mi[ls]+=tag[rt];
    mi1[ls]+=tag[rt];
    mi2[ls]+=tag[rt];
    tag[ls]+=tag[rt];
    mi[rs]+=tag[rt];
    mi1[rs]+=tag[rt];
    mi2[rs]+=tag[rt];
    tag[rs]+=tag[rt];
    tag[rt]=0;
}
void build(int l,int r,int rt)
{
    if(l==r)
    {
        mi[rt]=mi1[rt]=mi2[rt]=1e18;
        tag[rt]=0;
        return;
    }
    int mid=l+r>>1;
    build(l,mid,ls);
    build(mid+1,r,rs);
    pup(rt);
}
void add(int L,int R,ll v,int l,int r,int rt)
{
    if(L==l&&R==r)
    {
        mi[rt]+=v;
        mi1[rt]+=v;
        mi2[rt]+=v;
        tag[rt]+=v;
        return;
    }
    int mid=l+r>>1;
    if(tag[rt])pdw(rt);
    if(R<=mid)add(L,R,v,l,mid,ls);
    else if(L>mid)add(L,R,v,mid+1,r,rs);
    else
    {
        add(L,mid,v,l,mid,ls);
        add(mid+1,R,v,mid+1,r,rs);
    }
    pup(rt);
}
void upd(int pos,ll v,int l,int r,int rt)
{
    if(l==pos&&pos==r)
    {
        if(mi[rt]>v)
        {
            mi[rt]=v;
            mi1[rt]=v-pos;
            mi2[rt]=v+pos;
        }
        return;
    }
    int mid=l+r>>1;
    if(tag[rt])pdw(rt);
    if(pos<=mid)upd(pos,v,l,mid,ls);
    else upd(pos,v,mid+1,r,rs);
    pup(rt);
}
ll gao(int L,int R,int l,int r,int rt,ll *mi)
{
    if(L==l&&R==r)return mi[rt];
    int mid=l+r>>1;
    if(tag[rt])pdw(rt);
    if(R<=mid)return gao(L,R,l,mid,ls,mi);
    else if(L>mid)return gao(L,R,mid+1,r,rs,mi);
    else return min(gao(L,mid,l,mid,ls,mi),gao(mid+1,R,mid+1,r,rs,mi));
}
int main()
{
    int i,j;
    scanf("%d%d%d%d",&n,&q,&a,&b);
    build(1,n,1);
    upd(b,0,1,n,1);
    int pre=a;
    rep(i,1,q)
    {
        int x;
        scanf("%d",&x);
        ll cost1=gao(1,x,1,n,1,mi1)+x;
        ll cost2=gao(x,n,1,n,1,mi2)-x;
        ll now=min(cost1,cost2);
        add(1,n,abs(x-pre),1,n,1);
        upd(pre,now,1,n,1);
        pre=x;
    }
    printf("%lld\n",gao(1,n,1,n,1,mi));
    return 0;
}


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

int main() {
	string s;
	cin>>s;
	int s1=(s[0]-'0')*10+s[1]-'0';
	int s2=(s[2]-'0')*10+s[3]-'0';
	bool m1=(s1>0 && s1<=12), m2=(s2>0 && s2<=12);
	bool v1=(s1==0), v2=(s2==0);
	bool inval = (v1 && !m2) || (!m1 && v2) || (!m1 && !m2);
	if (inval) cout<<"NA"<<endl;
	else if (m1 && !m2) cout<<"MMYY"<<endl;
	else if (m2 && !m1) cout<<"YYMM"<<endl;
	else cout<<"AMBIGUOUS"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
 
 
bool judging(int x, int y, int z)  //widthes of three edges
{
    if (x * x + y * y == z * z) {
        return true;
    } else if (z * z + x * x == y * y) {
        return true;
    } else if (y * y + z * z == x * x) {
        return true;
    } else {
        return false;
    }
}
 
 
int main()
{
    int a, b, c, n;  //the number of lines
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> a >> b >> c;
        if (judging(a, b, c)) {
            std::cout << "YES" << std::endl;
        } else {
            std::cout << "NO" << std::endl;
        }
    }
}

Measured memory_bytes: 1152
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-19 11:42:57
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n, m, R; cin >> n >> m >> R;
  vector<int> r(R); cin >> r;
  for_each(all(r), [](int& e){--e;});

  const int inf = (int) 1e9;

  int dis[202][202];

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == j) {
        dis[i][j] = 0;
      } else {
        dis[i][j] = inf;
      }
    }
  }

  for (int i = 0; i < m; ++i) {
    int a, b, c; cin >> a >> b >> c;
    --a; --b;
    dis[a][b] = dis[b][a] = c;
  }

  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }

  sort(all(r));

  int ans = inf;

  do {
    int t = 0;
    for (int i = 0; i < R - 1; ++i) {
      t += dis[r[i]][r[i + 1]];
    }
    ans = min(ans, t);
  } while (next_permutation(all(r)));

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

class SEGTREE {
    unsigned int n;
    ll dflt;
    vector<ll> dat;

    static ll op(const ll a, const ll b) {
        return max(a, b);
    }

    bool f(const unsigned int id, const ll a){
        return dat[id] >= a;
    }

public:
    SEGTREE(unsigned long _n, ll _a) : n(1), dflt(_a) {
        while (n < _n) {n *= 2;}
        dat.resize(n * 2, dflt);
    }

    void update(unsigned int k, ll a) {
        k += n;
        dat[k] = a;
        while (k > 0) {
            k >>= 1;
            dat[k] = op(dat[k<<1], dat[(k<<1)|1]);
        }
    }

    void init(vector<ll> &v) {
        for (int i = 0; i < (int)v.size(); ++i) dat[i + n] = v[i];
        for (int i = n - 1; i >= 1; --i) {
            dat[i] = op(dat[i * 2], dat[i * 2 + 1]);
        }
    }

    ll query(unsigned int l, unsigned int r) {
        ll res_left = dflt, res_right = dflt;
        l += n; r += n;
        for ( ; l < r; l >>= 1, r >>= 1){
            if(l&1){
                res_left = op(res_left, dat[l]);
                if((++l) == r) break;
            }
            if(r&1){
                res_right = op(dat[r ^ 1], res_right);
            }
        }
        return op(res_left, res_right);
    }

    unsigned int max_right_search(unsigned int id, ll a){
        while(id < n) id = (id<<1) | !f(id<<1, a);
        return id - n;
    }

    unsigned int max_right(unsigned int l, unsigned int r, ll a){
        //[l, r)内のindexであるjであって、query(l, j) < a <= query(l, j + 1)なるものを求める
        //つまり、j >= l かつ dat[j] >= a である最小の数jを求める(func = maxの場合)
        unsigned int see_after = r + n;
        l += n;
        for (unsigned int tr = r + n ; l < tr; l >>= 1, tr >>= 1){
            if(l&1){
                if(f(l, a)) return max_right_search(l, a);
                if((++l) == tr) break;
            }
            if((tr&1) && f(tr ^ 1, a)) see_after = tr ^ 1;
        }
        return see_after == r + n ? r : max_right_search(see_after, a);
    }

    //単項にアクセスする[]だが、書き換え厳禁
    //一応後でinitすれば書き換えてもよさそうだが…
    ll &operator[](int k) { return dat[k + n]; }
};
int main() {
    cin>>N>>Q;
    vec a(N);
    rep(i, N) scanf("%lld", &a[i]);
    SEGTREE seg(N, 0);
    seg.init(a);
    rep(_, Q){
        int t, x, v, l, r;
        scanf("%d", &t);
        if(t == 1){
            scanf("%d%d", &x, &v); --x;
            seg.update(x, v);
        }else if(t == 2){
            scanf("%d%d", &l, &r);
            printf("%lld\n", seg.query(l - 1, r));
        }else{
            scanf("%d%d", &x, &v); --x;
            printf("%u\n", seg.max_right(x, (unsigned int) N, v) + 1);
        }
    }
}



Measured memory_bytes: 9152
S = input()

S = S[::-1]

while len(S) > 0:
  if S[0:5] == "dream"[::-1]:
    S = S[5:]
    continue
  elif S[0:7] == "dreamer"[::-1]:
    S = S[7:]
    continue
  elif S[0:5] == "erase"[::-1]:
    S = S[5:]
    continue
  elif S[0:6] == "eraser"[::-1]:
    S = S[6:]
    continue
  else:
    print("NO")
    exit(0)

print("YES")

Measured memory_bytes: 3188
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
using namespace std;

int main() {
int A, B, C, K, ans;
  cin >> A >> B >> C >> K;
  if(K <= A){
    cout << K << endl;
  }

   else if(K-A <= B){
      cout << A << endl;
    }
   else if(K-A-B <= C){
      cout << A - (K-A-B) << endl;
    }
  
  
  
    

}


Measured memory_bytes: 3624
using System;
using System.Linq;

namespace ABC092B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] dx = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(Enumerable.Repeat(0, n).Select(_ => int.Parse(Console.ReadLine())).Sum(x => (dx[0] - 1) / x + 1) + dx[1]);
        }
    }
}

Measured memory_bytes: 11348
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int N = (int)1e5 + 228;

using namespace std;

int n, a[N], b[N];

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//~read
	scanf("%d", &n);
	forn(i, n)
	{
		scanf("%d", &a[i]);
		b[i] = a[i];	
	}	
	sort(b + 1, b + n + 1);
	forn(i, n)
	{
		a[i] = lower_bound(b + 1, b + n + 1, a[i]) - b;
	}
	int x = 0, y = 0;
	forn(i, n)
	{
		if (i & 1)
			x += bool(a[i] % 2 == 0);
		else
			y += a[i] % 2;		
	}
	cout << max(x, y) << endl;

	return 0;
}



Measured memory_bytes: 1024
a,b=map(int,input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

l=make_divisors(a)
ll=[]

def gcd(x,y):
    if x==y:
        return x
    elif x>y:
        r=-1
        while r!=0:
            r=x%y
            x=y
            y=r
        return x
    else:
        r=-1
        while r!=0:
            r=y%x
            y=x
            x=r
        return y


for x in l:
    if x==1:
        continue
    if b%x==0:
        ll.append(x)
ansl=[1]
for x in ll:
    f=1
    for y in ansl:
        if gcd(x,y)!=1:
            f=0
    if f:
        ansl.append(x)


print(len(set(ansl)))


Measured memory_bytes: 41580
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N;
int chief[1024];
int dp[1024][8];

int toChief(char c){
  return c=='J'?0:c=='O'?1:2;
}

int dfs(int n, int prev){
  if(n==N) return 1;
  int &res = dp[n][prev];
  if(res >= 0) return res;
  res = 0;
  rep(i, 1<<3){
    if(!((i>>chief[n])&1)) continue;
    if(!(prev&i)) continue;
    res = (res+dfs(n+1, i))%10007;
  }
  return res;
}

int main(){
  string str;
  cin >> N >> str;
  rep(i, N) chief[i] = toChief(str[i]);
  int res = 0;
  memset(dp, -1, sizeof(dp));
  REP(i, 1, 1<<3) if((i>>chief[0])&1 && i&1)res = (res+dfs(1, i))%10007;
  printf("%d\n", res);
  return 0;
}

Measured memory_bytes: 1320
for _ in range(10000):
    n,x=map(int,input().split())
    cnt = 0
    if n==0 and x==0:
        break
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k==x:
                    cnt += 1
    print(cnt)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    double r;
    cin >> r;
    double pi = 3.1415926535;
    cout << 2 * pi * r << endl;
    
}

Measured memory_bytes: 3776
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int n;
    scanf("%lld", &n);
    vector<long long int> v(n);
    long long int x = 0, y = 0;
    REP(i,n){
        scanf("%lld",&v[i]);
        y += v[i];
    }

    long long int result = linf;

    REP(i,n-1){

        x += v[i];
        y -= v[i];

        result = min(result, abs(x - y));
    }

    cout << result << endl;




    



    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(){
	int a, b;
	while(scanf("%d %d", &a, &b) != EOF){
		//int a, b;
		//scanf("%d %d", &a, &b);
		int sum = a + b;
		int count = 1;
		int compare = 10;
		while(1){
			if(sum < compare){
				break;
			}
			++count;
			compare *= 10;
		}
		printf("%d\n", count);
	}
	return 0;
}

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

int main(){
  string S;
  cin >> S;
  if(S[2] == S[3] && S[4] == S[5])cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main() {
  	int a,n,b,d;
  	cin >> a >> n >> b;
  /* a*n円とb円を比べて小さいほう➡a*n<bまたはa*n>b */
  	d = a * n;
  	if (d < b) {
      cout << d << endl;
  	}
	else {
      cout << b << endl;
  }
}

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

const int mod = 1e9 + 7;

int exp(int x, int n) {
    int ret = 1;
    while(n) {
        if(n & 1) ret = 1LL * ret * x % mod;
        x = 1LL * x * x % mod;
        n >>= 1;
    }
    return ret;
}

int N, K, ans;
vector<int> Dv;
int add[100000];

int main() {
    scanf("%d %d", &N, &K);

    ans = 0;
    ans += 1LL * exp(K, (N + 1) / 2) * (N % 2 == 0? N / 2 : N) % mod;
    ans %= mod;

    for(int i = 1; i <= sqrt(N); i++) {
        if(N % i == 0) {
            Dv.push_back(i);
            Dv.push_back(N / i);
        }
    }
    sort(Dv.begin(), Dv.end());

    for(int i = 0; i < Dv.size(); i++) {
        int d = Dv[i];
        if(d == N) break;

        add[i] += exp(K, (d + 1) / 2);

        for(int j = 0; j < i; j++) {
            if(Dv[i] % Dv[j] == 0) {
                add[i] += mod - add[j];
                add[i] %= mod;
            }
        }

        ans += mod - 1LL * add[i] * ((N % 2 == 0? N / 2 : N) - (d % 2 == 0? d / 2 : d)) % mod;
        ans %= mod;
    }

    cout << ans;
}


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

typedef long long ll;

const long double PI = (acos(-1));


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

  ll a, b;
  cin >> a >> b;

  if (a < b) swap(a, b);

  ll x = a * b;
  ll r = a % b;
  while(r != 0){
    a = b;
    b = r;
    r = a % b;
  }

  cout << x / b << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#define rep(i,N) for(int i=0;i<(N);i++)
#define PI 3.1415926535897932
using namespace std;

struct UnionFind{
	vector<int> par;
	//初期化コンストラクタ
	UnionFind(int N) {
		par = vector<int>(N,-1);
	}

	int root(int x){
		if(par[x] < 0)return x;
		return par[x] = root(par[x]);
	}
	//統合_xのrootのrxのrootをryにする(x,yを同じルートにする)
	bool unite(int x, int y){
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return false;
		if(par[rx]>par[ry]) swap(rx,ry);//必ず大きい方をrxとする(後の記述が減る)
		par[rx]+=par[ry];
		par[ry] = rx;//yの親をxの親にする
		return true;
	}
	//x,yのrootが同じならtrue,異なればfalseを返す
	bool same(int x, int y){
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
	int size(int x){
		//xの属するグループのサイズを求める
		return -par[root(x)];
	}
};

int main(){
	int N,M;
	cin>>N>>M;
	//structの中のUnionFind(int N)で定義されたベクトルpar(N)を作る。
	UnionFind uf(N);
	for(int i=0;i<M;i++){
		int A,B;
		cin >> A >> B;
		//グループは0~N-1なので、-1して各グループに統合する
		A-=1;B-=1;
		//入力されたA,Bは同じグループ
		uf.unite(A,B);
	}
	int ans = 0;
	//答えはもっとも大きいufベクトルのサイズである。
	for(int i=0;i<N;i++){
		ans=max(ans,uf.size(i));
	}
	cout<<ans<<endl;

	
}

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



int main(){
  double a,b,h,m;
  double pi=acos(-1);
  // std::cout << pi << '\n';
  std::cin >> a>>b>>h>>m;
  double hk,mk;

  hk=-(h*60+m)/2;
  mk=-(h*60+m)/0.16666666666666666;

  // std::cout <<"角度"<< hk <<":"<<mk<<'\n';

  while (hk<0) {
    hk+=360;
  }

  while (mk<0) {
    mk+=360;
  }






  hk=hk*(pi/180.0);
  mk=mk*(pi/180.0);




  double hx,hy,mx,my;

  hx=a*cos(hk);
  hy=a*sin(hk);

  mx=b*cos(mk);
  my=b*sin(mk);


  // std::cout << hx<<"  "<<hy << '\n';
  // std::cout << mx<<"  "<<my << '\n';
  // std::cout << "" << '\n';

  if(-0.0000000001<hx && hx<0.0000000001)hx=0;
  if(-0.0000000001<hy && hy<0.0000000001)hy=0;
  if(-0.0000000001<mx && mx<0.0000000001)mx=0;
  if(-0.0000000001<my && my<0.0000000001)my=0;


  // std::cout << hx<<"  "<<hy << '\n';
  // std::cout << mx<<"  "<<my << '\n';




  double ans=sqrt( pow((hx-mx),2)+pow((hy-my),2) );
  printf("%3.10lf\n",ans);





  return 0;
}


Measured memory_bytes: 4108
unittest
{
	assert( [ "4 4", "2 4", "1 1", "2 3", "2 4" ].solve == "1\n3\n6\n-1" );
}



import std.algorithm;
import std.container;
import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto h = 0L;
	auto w = 0L;
	input.front.formattedRead!"%s %s"( h, w );
	auto abs = new long[ 2 ][ h ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
		ab[ 0 ] -= 1;
	}
	
	auto anss = new long[ h ];
	auto rbt = redBlackTree( iota( 0L, w ) );
	auto st = SegmentTree!( long, min, long.max )( new long[ w + 1 ] );
	foreach( y, ref ans, ab; lockstep( anss, abs ) )
	{
		auto xs = rbt.upperBound( ab[ 0 ] - 1 );
		auto p = false;
		while( !xs.empty && xs.front < ab[ 1 ] )
		{
			auto x = xs.front;
			xs.popFront;
			rbt.removeKey( x );
			st.set( ab[ 1 ], min( st.get( ab[ 1 ] ), st.get( x ) + ab[ 1 ] - x ) );
			st.set( x, long.max );
			p = true;
		}
		if( p && ab[ 1 ] < w ) rbt.insert( ab[ 1 ] );
		auto m = st.query( 0, w );
		if( m == long.max ) ans = -1;
		else                ans = y + 1 + m;
	}
	return anss.to!( string[] ).join( "\n" );
}

// セグメント木
struct SegmentTree( T, alias op = ( ( a, b ) => a + b ), T I = T.init )
{
	T[] ts;
	
	this( long n )
	{
/*
		// opについて交換法則 ( A op B ) op C == A op ( B op C ) が成り立たないときはnを2^^xに切り上げする
		auto m = 1L;
		while( m < n ){ m <<= 1; }
		ts = new T[ m << 1 ];
*/
		ts = new T[ n << 1 ];
		static if( I != T.init ) ts[] = I;
	}
	
	this( T[] qs )
	{
/*
		// opについて交換法則 ( A op B ) op C == A op ( B op C ) が成り立たないときはnを2^^xに切り上げする
		auto n = 1L;
		while( n < qs.length ){ n <<= 1; }
		ts = new T[ n << 1 ];
*/
		ts = new T[ qs.length << 1 ];
		ts[ $ >> 1 .. ( $ >> 1 ) + qs.length ] = qs;
		foreach_reverse( i; 1L .. ts.length.signed >> 1 )
		{
			ts[ i ] = op( ts[ i << 1 ], ts[ i << 1 | 1 ] );
		}
	}
	
	void set( long i, T v )
	{
		i += ts.length.signed >> 1;
		ts[ i ] = v;
		for( i >>= 1; 0 < i; i >>= 1 )
		{
			ts[ i ] = op( ts[ i << 1 ], ts[ i << 1 | 1 ] );
		}
	}
	
	auto get( long i )
	{
		i += ts.length.signed >> 1;
		return ts[ i ];
	}
	
	auto query( long l, long r )
	{
		l += ts.length.signed >> 1;
		r += ts.length.signed >> 1;
		auto x = I;
		auto y = I;
		for( ; l < r; l >>= 1, r >>= 1 )
		{
			if( l & 1 )
			{
				x = op( x, ts[ l ] );
				l++;
			}
			if( r & 1 )
			{
				r--;
				y = op( ts[ r ], y );
			}
		}
		return op( x, y );
	}
	
	auto length()
	{
		return ts.length >> 1;
	}
	
	auto toString()
	{
		return format( "ST(%s)", ts[ $ >> 1 .. $ ] );
	}
}


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

typedef long long ll;


#define all(c) (c).begin(),(c).end()
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,a,q) for(int i = a; q > i; i++)
#define pb push_back
#define int ll
#define MAX 1000000000
#define mod 1000000007
/*
確認ポイント
to_string() はC++11以降の実装;
length(),size()に括弧をつけ忘れてないか;
大文字小文字間違えてないか
*/
signed main() { 
    string S,T;
    vector<char> ue;
    vector<char> sita;
    char alpha[26] = {'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'};
    cin >> S >> T;
    bool outt = false;
    
    rep(i,26){
      int hatu = 0;
      rep(j,S.size()){
        if(alpha[i] != S[j]) continue;
        if(hatu != 0){
          repp(i,ue.size()-hatu,ue.size()){
            if(sita[i] == T[j]) continue;
            outt = true;
            break;
          }
        }
        if(S[j] == alpha[i]){
          ue.pb(S[j]);sita.pb(T[j]);
        }
      }
    }
    rep(i,26){
      char seikai =  '-';
      rep(j,sita.size()){
        if(alpha[i] == sita[j]){
          if(seikai == '-'){
            seikai = ue[j];
          } else {
            if(seikai != ue[j]){
              outt = true;
            }
          }
        }
      }
    }
    rep(i,26){
      char seikai = '-';
      rep(j,ue.size()){
        if(alpha[i] == ue[j]){
          if(seikai == '-'){
            seikai = sita[j];
          } else {
            if(seikai != sita[j]){
              outt = true;
            }
          }
        }
      }
    }
    if(outt) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0; 
} 

Measured memory_bytes: 1284
// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;

LL n, m;

int main(int argc, char const *argv[]) {
    cin >> n >> m;
    if (n == 1 || m == 1) {
        puts("1");
        return 0;
    }
    cout << (n * m + 1) / 2 << endl;

    // code
    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);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();
		int score = 0;
		
		while(a > 0 && k > 0) {
			score++;
			k -= 1;
			a -= 1;
		}
		while(b > 0 && k > 0) {
			k -= 1;
			b -= 1;
		}
		while(c > 0 && k > 0) {
			score--;
			k -= 1;
			c -= 1;
		}
		System.out.println(score);
	}

}


Measured memory_bytes: 35772
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define rev(a,b,c) for(int a=b;a>=c;a--)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define F first
#define S second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define get(a) cin>>a
#define nextl cout<<"\n"
#define deb(x) cout<<#x<<"="<<x<<"\n";
const ll mod = 1000000007;
const ll maxn = 500005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
ll ncr(ll n, ll k)
{
    ll C[k+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = (C[j] + C[j-1])%mod;
    }
    return C[k];
}
void solve()
{
    ll n;
    cin>>n;
    if(n%2){
        cout<<0;
        return;
    }
    ll x=10;
    ll ans=0;
    while(x<=n){
        ans+=n/x;
        x*=5;
    }
    pr(ans);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
       // nextl;
    }
    return 0;
}


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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int X,Y,Z;
	int V[4];
	int E[51];
	int A[51];
	double dp[51][5001];
	while(1){
		REP(i,51){
			E[i] = 0; A[i] = 0;
		}
		REP(i,51) REP(j,5001) dp[i][j] = 0;
		cin >> X >> Y >> Z;
		if(X==0&&Y==0&&Z==0) break;
		REP(i,X) cin >> V[i];
		REP(i,Z){
			int n,e,a;
			cin >> n >> e >> a;
			E[n] = e;
			A[n] = a;
		}

		//dp[i][j] i??????????????????j????????£??????????¢????
		dp[0][0] = 1.0;
		REP(i,Y){
			REP(j,5001){
				REP(k,X){
					int next = i + V[k];
					int money = j;
					if(next >= Y) next = Y;
					if(E[next] == 1){
						next += A[next];
						if(next >= Y) next = Y;
					}else if(E[next] == 2){
						money += A[next];
					}else if(E[next] == 3){
						money -= A[next];
					}
					if(money < 0) money = 0;
					dp[next][money] += dp[i][j] / (double)X;
				}
			}
		}
		double sum = 0;
		REP(i,5001) sum += i*dp[Y][i];
		cout << (int)sum << endl;
	}
}

Measured memory_bytes: 3152
cha = "MARCH"
dic = {}

N = int(input())

for i in range(N):

    S = input()

    if S[0] in cha and S[0] not in dic:

        dic[S[0]] = 1

    elif S[0] in cha:

        dic[S[0]] += 1

ans = 0

for i in dic:

    for j in dic:

        if i == j:
            break

        for k in dic:

            if j == k or i == k:
                break

            ans += dic[i]*dic[j]*dic[k]

print (ans)


Measured memory_bytes: 3064
n,m,c = list(map(int,input().split()))
b= [int(i) for i in input().split()]
count = 0
for i in range(0,n):
    s = 0
    a = [int(i) for i in input().split()]
    for k in range(0,m):
        s += a[k]*b[k]
    if s + c > 0:
        count += 1
print(count)

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

int main() {

	int N, X;
	cin >> N >> X;

	vector<int>L;
	vector<int>bounce;

	bounce.push_back(0);

	int d = 0;
	for (int i = 1; i <= N; i++) {
		int l;
		cin >> l;
		d += l;
		bounce.push_back(d);
	}
	int count=0;

	for (int i = 0; i < bounce.size(); i++) {
		if (bounce[i] <= X) {
			count++;
		}
		else {
			break;
		}
	}

	cout << count << endl;

	

	return 0;

}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque

H,W=map(int, sys.stdin.readline().split())
CH,CW=map(int, sys.stdin.readline().split())
CH-=1
CW-=1
DH,DW=map(int, sys.stdin.readline().split())
DH-=1
DW-=1
S=[ sys.stdin.readline().strip() for _ in range(H) ]

D=[(0,1),(0,-1),(1,0),(-1,0)]
WARP=[]
for dh in range(-2,3):
    for dw in range(-2,3):
        if abs(dh)+abs(dw)<=1: continue
        WARP.append((dh,dw))

visit=defaultdict(lambda: 0) #0:未訪問、1:訪問済み
d=defaultdict(lambda: float("inf")) #スタート地点から各マスまでの距離

q=deque()
q.append((CH,CW))
d[(CH,CW)]=0

while q:
    fro_h, fro_w=q.popleft()
    if fro_h==DH and fro_w==DW:
        print d[(fro_h, fro_w)]
        quit()
    for dh,dw in D:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]=="." and d[(fro_h, fro_w)]<d[(to_h, to_w)]:
            d[(to_h, to_w)]=d[(fro_h, fro_w)]
            q.appendleft((to_h, to_w))

    for dh,dw in WARP:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]=="." and d[(fro_h, fro_w)]+1<d[(to_h, to_w)]:
            d[(to_h, to_w)]=d[(fro_h, fro_w)]+1
            q.append((to_h, to_w))

print -1

Measured memory_bytes: 183888
# import math
# import statistics
a=int(input())
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#    c.append(i)
# e1,e2 = map(int,input().split())
# f = list(map(int,input().split()))
#g = [input() for _ in range(a)]

da=True
ap=[a]
count=1
while da:
    if a%2==0:
        a=a//2
        ap.append(a)
    elif a%2==1:
        a=3*a+1
        ap.append(a)
    count+=1
    if len(set(ap))<len(ap):
        print(count)
        da=False


Measured memory_bytes: 9112
N = int(input())
A = list(map(int,input().split()))
ans = 0
def GCD(a,b):
    if a < b:
        a,b = b,a
    while a % b != 0:
        a,b = b, a % b
    return b
if __name__ =="__main__":
    for i in range(N-1):
       A[i+1] = GCD(A[i],A[i+1])
    while A[N-1] % 2 == 0:
        A[N-1] //= 2
        ans += 1
    print(ans)

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

int n,k;
long long int search(int w[],int left,int right){
	int mid;
	int truck;
	int weight;
	while(right-left>3){
		mid=(right+left)/2;
		truck=1;//何台目か
		weight=0;//トラックに載っている荷物の重さ
		for(int i=0;i<n;i++){
			if(w[i]>mid){
				truck=1000000;
				break;
			}
			else if(weight+w[i]>mid){
				truck++;
				weight=w[i];
			}
			else	weight+=w[i];
			if(weight==mid&&i!=n-1){
				truck++;
				weight=0;
			}
		}
		if(truck>k)	left=mid-1;
		else 	right=mid+1;
	}
	/*ここから線形探索*/
	for(mid=right;mid>=left;mid--){
		truck=1;
		weight=0;
		for(int i=0;i<n;i++){
			if(w[i]>mid){
				truck=1000000;
				break;
			}
			else if(weight+w[i]>mid){
				truck++;
				weight=w[i];
			}
			else	weight+=w[i];
			if(weight==mid&&i!=n-1){
				truck++;
				weight=0;
			}
		}
		if(truck>k){
			break;
		}
	}
	return mid+1;
}
		

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>n>>k;
	int w[n];
	int sum=0,min=100000;
	for(int i=0;i<n;i++){
		cin>>w[i];
		sum+=w[i];
		min=min<w[i]?min:w[i];
	}
	cout<<search(w,min,sum)<<endl;
	return 0;
}

Measured memory_bytes: 1580
ringstr = input()
search = input()
ans = False
for i,ch in enumerate(ringstr):
    if ch == search[0]:
        ans = True
        for itr,j in enumerate(range(i,i+len(search))):
            if search[itr] != ringstr[j%len(ringstr)]:
                ans = False
                break

        if ans:
            break

if ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5564
mod = 10**9 + 7

def modpow(x, n):
    res = 1
    while n > 0:
        if n & 1 == 1:
            res = res*x%mod
        x = x*x%mod
        n >>= 1
    return res

N = int(input())
ans = (modpow(10,N)-2*modpow(9,N)+modpow(8,N))%mod

print(ans)


Measured memory_bytes: 61816
#include<iostream>
#include<vector>

using namespace std;

int main()
{
	int i,j;
	int num[100]={0};
	int a;
	int max=0;
	vector<int> ans;
	
	for(i=0;cin >> a;i++)
	{
		num[a]++;
		
		for(j=0;j<i;j++)
		{
			if(num[j]>max)
			{
				max=num[j];
			}
		}
	}
	
	for(j=0;j<i;j++)
		if(num[j]==max)
			ans.push_back(j);
		vector<int>::iterator it = ans.begin();
	for(;it!=ans.end();++it)
		cout << *it << endl;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
#include<math.h> 
#include<algorithm> 
#include<stdio.h> 
#include<sstream>
#include<fstream>  
using namespace std; 
typedef long long ll; 
typedef long double ld; 

int ceil(int a, int m){
    // division of a and m
    if(a % m == 0){
        return a/m; 
    }
    else{
        return a/m + 1; 
    }
}

vector<int> sort(vector<int> arr){
    sort(arr.begin(), arr.end()); 
    return arr; 
}

int minInVector(vector<int> arr){
    int mins = 1e9; 
    for(int i = 0; i<arr.size(); i++){
        mins = min(mins, arr[i]); 
    }
    return mins; 
}

int maxInVector(vector<int> arr){
    int maxs = -1; 
    for(int i = 0; i<arr.size(); i++){
        maxs = max(maxs, arr[i]); 
    }
    return maxs; 
}

bool checkElement(vector<int> arr, int k){
    for(int i = 0; i<arr.size(); i++){
        if(arr[i] == k){
            return true; 
        }
    }
    return false; 
}


void solve(){
string a; 
cin >> a; 
ll cur = 0; 

for(char b: a){
    cur+=(b-'0' % 9); 
}
cout << (cur%9 == 0 ? "Yes": "No"); 
}

char nl = '\n'; 
char bl = ' ';
const int MOD = 1e9 + 7; 



int main(){

ios_base::sync_with_stdio(false);
cin.tie(NULL); 

/*
For array arr use the following preamble to sort
int diff = sizeof(arr)/sizeof(arr[0]); 
sort(arr, arr + diff); 

*/

solve(); 


}



Measured memory_bytes: 3744
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s; cin >> s;
	string a, b;
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0)a += s[i];
		else b += s[i];
	}
	string t; cin >> t;
	if (s.size() == 1) { cout << "Yes\n"; return 0; }
	int acnt = 0, bcnt = 0;
	for (int i = 0; i < t.size(); i++) {
		if (a[acnt] == t[i]) {
			acnt++; if (acnt == a.size()) {
				cout << "Yes\n"; return 0;
			}
		}
		if (b[bcnt] == t[i]) {
			bcnt++; if (bcnt == b.size()) {
				cout << "Yes\n"; return 0;
			}
		}
	}
	cout << "No\n";
}

Measured memory_bytes: 3220
import java.util.Scanner;

public class Main {
   public static void main(String[] args) {
       Scanner s= new Scanner(System.in);
       String st = s.nextLine();
       String t = s.nextLine();
       int count = 0, len =st.length();
       for(int i = 0;i < len; ++i) {
           if(st.charAt(i)!=t.charAt(i))
               count++;
       }
       System.out.println(count);
   }
}


Measured memory_bytes: 42336
n, m, x = map(int, input().split())
ar = [[int(_) for _ in input().split()] for _ in range(n)]

poss, best = 0, 10**9
for mask in range(2**n):
    lv = [0] * m
    cost = 0
    for bit in range(n):
        if (1 << bit) & mask:
            cost += ar[bit][0]
            for i in range(m):
                lv[i] += ar[bit][i+1]
    if sorted(lv)[0] >= x:
        poss = 1
        best = min(best, cost)
print(-1 if poss == 0 else best)

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

#define MAX 10000001

bool is_prime[MAX];

void Sieve() {
  fill(is_prime, is_prime + MAX, true);
  is_prime[0] = is_prime[1] = false;
  
  for(int i=2; i*i<MAX; i++) {
    if(is_prime[i]) {
      for(int j=i*i; j<MAX; j+=i)
	is_prime[j] = false;
    }
  }
}

int main() {
  
  Sieve();
  
  int n;
  while(cin >> n && n) {
    for(int i=n-8; i>=0; i--) {
      if(is_prime[i] && is_prime[i+2] && is_prime[i+6] && is_prime[i+8]) {
	cout << i+8 << endl;
	break;
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 10928