akhauriyash/Code-Regression huggingface dataset:
#include <queue>
#include <cmath>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int n, m;
const int max_n = 15;
const int INF = 0x3f3f3f3f;

/*********************************************************

int dis[max_n][max_n];
void floyd(int m){
    for(int k = 0; k <= m; ++k)
        for(int i = 0; i <= m; ++i)
            for(int j = 0; j <= m; ++j)
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
}

*********************************************************/
/*********************************************************
//bool vis[max_n];
//int d[max_n];
void dijkstra(int s){
    memset(vis, false, sizeof(vis));
    memset(d,INF, sizeof(d));
    d[s] = 0;
    while(1){
        int index = -1;
        for(int j = 0; j <= m; ++j)
            if(!vis[j] && (index == -1 || d[j] < d[index])) index = j;
        if(index == -1) break;
        vis[index] = true;
        for(int j = 0; j <= m; ++j)
            d[j] = min(d[j], d[index] + dis[index][j]);
    }
}

*********************************************************/

int d[max_n];
bool vis[max_n];
int dis[max_n][max_n];
void spfa(int s){
    memset(d, INF, sizeof(d));
    memset(vis, false, sizeof(vis));
    vis[s] = true;
    d[s] = 0;
    queue<int> que;
    que.push(s);
    while(!que.empty()){
        int index = que.front();
        que.pop();
        vis[index] = false;
        for(int i = 0; i <= m; ++i)
            if(d[i] > d[index] + dis[index][i]){
                d[i] = d[index] + dis[index][i];
                if(!vis[i]) que.push(i), vis[i] = true;
            }
    }
}

/*********************************************************

//int d[max_n];
struct e{int from, to, cost;}p[max_n];
void bellman(int s){
    memset(d, INF, sizeof(d));
    d[s] = 0;
    while(true){
        bool update = false;
        for(int i = 0; i < n; ++i){
            if(d[p[i].from] != INF && d[p[i].to] < d[p[i].from] + p[i].cost)
                d[p[i].to] = d[p[i].from] + p[i].cost, update = true;
        }
        if(!update) break;
    }
}

*********************************************************/

int main(){
    ios::sync_with_stdio(false);
    while(cin >> n && n){
        for(int i = 0; i < max_n; ++i) fill(dis[i], dis[i] + max_n, INF), dis[i][i] = 0;
        m = 0;
        while(n--){
            int x, y, d;
            cin >> x >> y >> d;
            //cin >> p[i].from >> p[i].to >> p[i].cost;
            m = max(m, max(x, y));
            dis[x][y] = dis[y][x] = d;
        }
        //floyd(m);
        int ans = INF, index = 0;
        for(int i = 0; i <= m; ++i){
            //dijkstra(i);
            spfa(i);
            int temp = 0;
            for(int j = 0; j <= m; ++j) temp += d[j];
            if(temp < ans) ans = temp, index = i;
        }
        cout << index << " " << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1200
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

#別に誰も10^100なんて数が必要とはいってないのだ
def dp_resolvea():
    #シミュレーションをないーーーぶにやると(|s|^2+1)//2回必要なのでTLEするよ（乱択でごまかす方法をおもいつきませんでした）
    #一番長い移動を考えると、全部Rだった場合の
    #状態を圧縮するとシミュレーションできませんか？
    S=input()
    N=len(S)
    ans=[[1]*N,[0]*N]
    
    for i in range(1<<20):#2^20回くりかえしたら10^5回より増えるやろ->当然の権利のようにTLEします
        ans[(i+1)%2]=[0]*N
        for n in range(1,N-1):
            if S[n]=="R":ans[(i+1)%2][n]+=ans[i%2][n-1]
            else:ans[(i+1)%2][n]+=ans[i%2][n+1]
    
    print(*ans[0])
    return            

def dp_resolve():
    #そうです、状態遷移の回数を圧縮します　    
    S=input()
    N=len(S)
    dp=[[0]*N for i in range(20)]
    
    #ダブリングをするために、貰うDPにしたい
    #dp[moves][initial_position]=initial_positionの人のmoves回後のます(操作を数列の変換としてあつかう、とも言います）
    henkan=[0]*N
    for n in range(N):
        if S[n]=="R":
            henkan[n]=n+1
        else:henkan[n]=n-1
    #print(henkan)
    dp[0]=henkan
    
    for i in range(1,20):#25回だ！
        for m in range(N):
            dp[i][m]=dp[i-1][dp[i-1][m]]
    #print(dp)
    ans=[0]*N
    for k in range(N):
        ans[dp[-1][k]]+=1
    print(*ans)
    #これを20回にしたい
    #print(*ans[0])
    return              
def search_resolve():
    S=input()
    
    #Sのうち、連続する2文字が”RL”か、文末にだけ1以上がある
    #RLの効果が及ぶところごとに分割しよっか　LRの真ん中で分割
    N=len(S)
    sub=[N]#kugiri
    sub2=[]#"RL"のLの位置
    for i in range(N-1):
        cont=()
        if S[i]=="L"and S[i+1]=="R":
            sub.append(i+1)
        if S[i]=="R"and S[i+1]=="L":
            sub2.append(i+1)
    sub.sort(reverse=True)
    #print(sub,sub2)

    ans=[0]*N
    temp=[0,0]
    ind=0
    for i in range(N):
        l=sub2[ind]
        temp[(l-i)%2]+=1
        if i+1 in sub:
            ans[l]+=temp[0]
            ans[l-1]+=temp[1]
            temp=[0,0]
            ind+=1
            sub.pop()
            
            
    
    print(*ans)
    
def resolve():
    dp_resolve()
    #search_resolve()
#%%submit!
resolve()

Measured memory_bytes: 63804
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
  
int main() {
  int N;
  cin >> N;
  int x;
  int l;
  int r;
  
  rep(i,N){
    cin >> l >> r;
	x += r-l+1;
  }
  cout << x;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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



	char s, t;
	cin >> s >> t;
	if (s > t)
		cout << ">" << endl;
	else if (s == t)
		cout << "=" << endl;
	else
		cout << "<" << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int N,A[N],B[N],C[N-1];
    int ans=0;
    cin >>N;
    REP(i,N){
        cin>>A[i];
    }
    REP(i,N){
        cin>>B[i];
    }
    REP(i,N-1){
        cin>>C[i];
    }
    REP(i,N){
        ans+=B[A[i]-1];
        if(i!=N-1&&A[i+1]-A[i]==1) ans+=C[A[i]-1];
    }
    cout <<ans<<endl;
}

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

#define int long long

using namespace std;

const int maxn = 2e5 + 10;
int x[maxn], h[maxn], idx[maxn], a, d, n;
vector<int> event;

#define lc (v << 1)
#define rc (lc | 1)
#define tm (tl + tr >> 1)

int t[maxn << 2], lazy[maxn << 2];

void build(int v = 1, int tl = 0, int tr = n - 1)
{
    if (tl == tr)
        t[v] = h[tl];
    else
    {
        build(lc, tl, tm);
        build(rc, tm + 1, tr);
        t[v] = t[lc] + t[rc];
    }
}

void shift(int v)
{
    t[lc] += lazy[v];
    t[rc] += lazy[v];
    lazy[lc] += lazy[v];
    lazy[rc] += lazy[v];

    lazy[v] = 0;
}

void update(int l, int r, int x, int v = 1, int tl = 0, int tr = n - 1)
{
    if (l > r)
        return;
    if (tl == l && tr == r)
        t[v] += x, lazy[v] += x;
    else
    {
        shift(v);
        update(l, min(r, tm), x, lc, tl, tm);
        update(max(l, tm + 1), r, x, rc, tm + 1, tr);
        t[v] = t[lc] + t[rc];
    }
}

int get(int idx, int v = 1, int tl = 0, int tr = n - 1)
{
    if (tl == tr)
        return t[v];
    shift(v);
    return idx <= tm ? get(idx, lc, tl, tm) : get(idx, rc, tm + 1, tr);
}

signed main()
{
    ios::sync_with_stdio(false);
    cin >> n >> d >> a;

    vector<pair<int, int>> now;
    for (int i = 0; i < n; i++)
        cin >> x[i] >> h[i], now.push_back({x[i], h[i]});
    sort(now.begin(), now.end());

    for (int i = 0; i < n; i++)
        tie(x[i], h[i]) = now[i], event.push_back(x[i]);
    build();

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        int x = event[i], h = get(i);
        if (h <= 0)
            continue;
        int nxt = upper_bound(event.begin(), event.end(), x + 2 * d) - event.begin();
        ans += ((h += a - 1) /= a);
        update(i, nxt - 1, -h * a);
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 25196
<?php 
  
  fscanf(STDIN,'%d',$n);
  
  $found = false;
    for ($i = 0; $i <= $n/4; $i++) {
        for ($j = 0; $j <= $n/7; $j++) {
         if(((4 * $i) + (7 * $j))==$n){
            $found = true;
            break;
        }
    }
        if($found) {
            break;
        }
    }
    if($found){
        echo 'Yes';
    }else{
        echo 'No';    
    }

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

ll solve(int N, vi &A){
	sort(all(A));
	map<int,int> M;
	rpz(i,N){
		M[A[i]]++;
	}
	ll ans = 0;
	for(auto m:M){
		int a,c;tie(a,c)=m;
		if(c>a){
			ans += c-a;
		}
		else if(c<a){
			ans += c;
		}
	}
	return ans;
}

int main(){
	int N; cin>>N;
	vi A(N);
	rpz(i,N)cin>>A[i];
	ote(solve(N,A));
}


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

int main() {
    int64_t n, tmp = 0, s = 0;
    cin >> n;
    vector<string> v(n), t(n, "");
    rep(i, n) cin >> v[i];
    vector<vector<char>> r(n, vector<char>(10));
    rep(i, n){
        rep(j, 10) r[i][j] = v[i][j];
    }
    rep(i, n) sort(r[i].begin(), r[i].end());
    rep(i, n){
        rep(j, 10) t[i] += r[i][j];
    }
    sort(t.begin(), t.end());
    rep(i, n-1){
        if(t[i] == t[i+1]){
            ++tmp;
            s += tmp;
        }
        else tmp = 0;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 19840
import kotlin.math.*

fun main() {
    val l = readLine()!!.split(" ")
    val A = l[0].toDouble()
    val B = l[1].toDouble()
    val H = l[2].toInt()
    val M = l[3].toInt()

    val tha = (H*30 + M*0.5) * (PI/180)
    val thb = (M*6) * (PI/180)

    val th = abs(tha - thb)

    val c = sqrt(A*A + B*B - 2*A*B*cos(th))

    println("%.20f".format(c))
}

Measured memory_bytes: 36972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    int n, x;
    cin >> n >> x;
    int ans;
    vector<int> a(n);
    rep(i, n) {
        int a;
        cin >> a;
        if (i == 0) ans = abs(x - a);
        else {
            ans = gcd(ans, abs(x - a));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;
int main() {
  int n;
  double sum=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    if(i%3!=0&&i%5!=0){
      sum+=i;
    }
  }
  printf("%.0f\n",sum );
  return 0;
}


Measured memory_bytes: 3756
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define enter "\n"

typedef long long ll;


//int abc098_c(){
//    //入力
//    int n;
//    string s;
//    cin >> n >> s;
//    int ans=500000;
//
//    //処理
//    for(int i=0 ; i<n ; i++){
//        int tmp = 0;
//        string str1 = s.substr(0,i);
//        string str2 = s.substr(i+1);
//        tmp += count(str1.cbegin(), str1.cend(), 'W');
//        tmp += count(str2.cbegin(), str2.cend(), 'E');
//        ans = min(tmp , ans);
//    }
//
//    //出力
//    cout << ans << enter;
//    return 0;
//}
int abc098_c(){
    //入力
    int n;
    string s;
    cin >> n >> s;
    int ans=0;

    //処理
    for(int i=1 ; i<n ; ++i){
        if(s[i]=='E') ++ans;
    }
    int tmp = ans;
    for(int i=1 ; i<n ; i++){
        if(s[i]=='E' && s[i-1]=='E') --tmp;
        else if(s[i]=='W' && s[i-1]=='W') ++tmp;
        ans = min(ans,tmp);
    }

    //出力
    cout << ans << enter;
    return 0;
}

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


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n;
  cin >> n;

  ll p;
  map<ll, ll> a;
  REP(i, n){
    cin >> p;
    a[p] = i;
  }

  ll ans = 0;
  ll now = 1;
  for(ll i = 2; i <= n; i++){
    if(a[i] < a[i-1]){
      ans = max(ans, now);
      now = 1;
      continue;
    }
    now++;
  }

  ans = max(ans, now);

  cout << n-ans << endl;
  
}


Measured memory_bytes: 12800
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <math.h>
#include <iomanip>
#include <queue>
#include <map>
#include <list>
#include <set>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX 50
#define LARGENUM 1000000007
#define INF 9223372036854775807
#define ull unsigned long long 
typedef pair <int, int> P;

int main(){
    int N, A;
    cin >> N;
    int a[N], s[N];
    rep(i, N) cin >> a[i];
    A = a[0];
    for (int i = 1; i < N; i++){
        A = A ^ a[i];
    }
    rep(i, N){
        s[i] = A ^ a[i];
        //A = A ^ s[i];
    }
    rep(i, N){
        cout << s[i] << ' ';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 4660
#include<stdio.h>
#define N1 2000001
#define N2 2000001
#define M 10001

int array[N1], sort_array[N2], counting[M];

int main(){

  int i, n, k;

  for(i = 1; i < N2; i++)sort_array[i] = 0;
  for(i = 1; i < M; i++)counting[i] = 0;
  
  scanf("%d",&n);

  for(i = 1; i <= n; i++)
    {
      scanf("%d",&array[i]);
      counting[array[i]]++;
    }

  for(i = 0; i < M; i++)
    {
      counting[i + 1] += counting[i];
      /*
	for(k = 1; k < n; k++)printf("%d ",counting[k]);
	printf("\n");
      */
    }
  
  for(i = n; i >= 1; i--)
    {
      /*
	printf("--------------------------------\n");
	printf("counting\n\n");
	for(k = 1; k < n; k++)printf("%d ",counting[k]);
	printf("\n");
	printf("--------------------------------\n\n");
      */
      sort_array[counting[array[i]]] = array[i];
      counting[array[i]]--;
    }

  for(i = 1; i <=  n; i++)
    {
      if(i != 1)printf(" ");
      printf("%d",sort_array[i]);
      
    }
  printf("\n");
  
  
  
  return 0;
}



Measured memory_bytes: 17392
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

//２項定理(MOD使用)
const ll MAX = 510000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//素因数分解
vector<pair<ll,int>> factorize(ll n) {
  vector<pair<ll,int>> res;
  for (ll i = 2; i*i <= n; ++i) {
    if (n%i) continue;
    res.emplace_back(i,0);
    while (n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n,1);
  return res;
}

int main(void){
    ll n, m;
    cin >> n >> m;

    vector<pair<ll, int>> res = factorize(m);
    ll sum = 1;
    fore(a, res){
        COMinit();
        sum *= COM(a.second + n - 1, n - 1);
        sum %= MOD;
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 12160
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>

int main()
{
    int a, b, c;
    std::cin >> a >> b >> c;

    int val[3];
    val[0] = 10 * a + b + c;
    val[1] = a + 10 * b + c;
    val[2] = a + b + 10 * c;

    std::cout << std::max({val[0], val[1], val[2]}) << std::endl;


    return 0;
}

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

using namespace std;

int main(void){

  int graph[100][100];
  for( int i = 0 ; i < 100 ; i++ )
    for( int j = 0 ; j < 100 ; j++ )
      graph[i][j] = 0;

  int n;
  cin >> n;
  for( int i = 0 ; i < n ; i++ ){
    int u, k;
    cin >> u >> k;
    u--;
    while( k-- ){
      int v;
      cin >> v;
      v--;
      graph[u][v] = 1;
    }
  }
  for( int i = 0 ; i < n ; i++ ){
    for( int j = 0 ; j < n ; j++ ){
      if( j == n - 1 ) cout << graph[i][j] << endl;
      else cout << graph[i][j] << " ";
    }
  }
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    ll ans = 0;
    reps(i, 1, n) {
        ans += (n - 1) / i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#pragma GCC optimize(2)
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue<int, vector<int>, greater<int> > q;从小到大
#include <map>
#include <set> //multiset set<int,greater<int>>大到小
#include <vector>// vector<int>().swap(v);清空释放内存
#include <stack>
#include <cmath>
#include <utility>
#include <sstream>
#include <string>//__builtin_popcount(ans);//获取某个数二进制位1的个数
#define mod 1000000007
#define mod9 998244353
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
typedef long double ld;
const db eps=1e-7;
const db pi=acos(-1);
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
#define rep(i,be,en) for (int i=be;i<=en;i++)
using namespace std;
const int N=1e6+7;

int T,n,m,fl=0;

ll sum=0,ans=0;
int a,b,c,d;
int main(){
    scanf("%d%d%d%d",&a,&b,&c,&d);
    c=c*60+d;
    db x=(db)c*pi/30-c*pi/360;
    if(x<0) x*=-1;
    if(x>pi) x=2*pi-x;
    db y=(db)a*a+b*b-2*cos(x)*a*b;
    if(y<0) y*=-1;
    y=sqrt(y);
    printf("%.10lf\n",y);
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)

ll s;
ll _57577=0b10000001000000100001000000100001;

ll f(ll cnt){
	char ss[11];
	if(cnt){
		scanf(" %s",ss);
		ll t=f(cnt-1);
		s=s<<strlen(ss)|1;
		if((s&_57577)==_57577)return cnt;
		return t;
	}
	return -1;
}

int main(){
	ll cnt;
	while(scanf("%lld",&cnt),cnt){
		s=1;
		printf("%lld\n",cnt-f(cnt)+1);
	}
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define pb  push_back
#define mod 1000000007
#define INF 1e18
typedef  long long ll;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll x,k,d;		
	cin>>x>>k>>d;
	x=abs(x);
	if((x/d)>=k)
		cout<<abs(x)-(k*d);
	else
		(k%2==(x/d)%2)?cout<<(x%d):cout<<abs(min((x%d)+d,(x%d)-d));
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111
	
	bool isprime(int x){
	for(int i = 2;i*i<=x;i++){
		if(x%i == 0)return false;
	}
	return x!=1;
	}



	void solve(){


		ini(n);
		int tmp =n;
		vi morty;
		for (int  i = 2; i*i<=n; i++)
		{
			if(n%i == 0){
				while (n%i==0)
				{
					n/=i;
					morty.push_back(i);
				}
				
			}
		}
		if(n!=1)morty.push_back(n);
		cout<<tmp<<": ";
		FOR(i,0,morty.size()){
			cout<<morty[i];
			if(i!=morty.size()-1)cout<<" ";
		}
		out();
		
		

		


		
		
	}



	



















int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}



Measured memory_bytes: 3156
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N,p;
    cin >> N;
    ll i,cnt=0;
    for(i=0;i<N;i++){
        cin >> p;
        if(i+1!=p)cnt++;
    }
    if(cnt<=2)cout <<"YES";else cout <<"NO";
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(reader.readLine());
    int i = 1;
    CHECK_NUM:
    while (true) {
      int x = i;
      if (x % 3 == 0) {
        System.out.print(" " + i);
        if (++i <= n)
          continue;
        else
          break;
      }
      INCLUDE3:
      while (true) {
        if (x % 10 == 3) {
          System.out.print(" " + i);
          if (++i <= n)
            continue CHECK_NUM;
          else
            break CHECK_NUM;
        }
        x /= 10;
        if (x != 0); else {
          if (++i <= n)
            continue CHECK_NUM;
          else
            break CHECK_NUM;
        }
      }
    }
    System.out.println();
  }

}

Measured memory_bytes: 22056
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) {
        //コード
    	Scanner sc = new Scanner(System.in);
//    	File file = new File("src/in.txt");
//    	Scanner sc = new Scanner(file);

    	String S = sc.next();
    	String T = sc.next();

    	if(T.startsWith(S)) {
        	char[] s = S.toCharArray();
        	char[] t = T.toCharArray();

        	if(s.length + 1 == t.length){
        		char last = t[s.length];
        		String str = String.valueOf(last);
        		String az = "[a-z]";
        		Pattern p = Pattern.compile(az);
        		Matcher m = p.matcher(str);
        		if (m.find()) {
        			System.out.println("Yes");
        		} else {
        			System.out.println("No");
        		}


        	} else {
        		System.out.println("No");
        	}

    	} else {
    		System.out.println("No");
    	}


    }
}

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

int N, M;
vector<vector<int> > G;

vector<bool> seen;
bool rec(int v, int p, int s, int t) {
    if (v == s && p != -1) return true; // 一周回ってきて s に戻って来たら OK
    if (v != s) seen[v] = true;
    for (auto nv :  G[v]) {
        if (nv == p || nv == t || seen[nv]) continue;
        if (rec(nv, v, s, t)) return true;
    }
    return false;
}
        
bool solve() {
    cin >> N >> M;
    G.assign(N, vector<int>());
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    map<int,int> degs;
    for (int v = 0; v < N; ++v) degs[(int)G[v].size()]++;

    for (auto it : degs) if (it.first % 2 != 0) return false;
    if (degs[6] > 0) return true;
    if (degs[4] > 2) return true;
    if (degs[4] <= 1) return false;

    vector<int> four;
    for (int v = 0; v < N; ++v) if (G[v].size() == 4) four.push_back(v);
    int s = four[0], t = four[1];
    seen.assign(N, 0);
    return rec(s, -1, s, t);
}

int main() {
    if (solve()) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 7680
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		try {
			System.setIn(new FileInputStream("src/aoj0048/input.txt"));
			System.setOut(new PrintStream(new FileOutputStream("src/aoj0048/result.txt")));
		} catch (FileNotFoundException e) {
		}
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		for (double d; sc.hasNext();) {
			d = sc.nextDouble();
			String str;
			if (d <= 48.0)
				str = "light fly";
			else if (d <= 51.00)
				str = "fly";
			else if (d <= 54.00)
				str = "bantam";
			else if (d <= 57.00)
				str = "feather";
			else if (d <= 60.00)
				str = "light";
			else if (d <= 64.00)
				str = "light welter";
			else if (d <= 69)
				str = "welter";
			else if (d <= 75)
				str = "light middle";
			else if (d <= 81)
				str = "middle";
			else if (d <= 91)
				str = "light heavy";
			else
				str = "heavy";
			System.out.println(str);
		}
	}

	void debug(Object... os) {
		System.err.println(deepToString(os));
	}
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 998244353;




int main() {

	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;

	int f = (c - a) * 60;
	f += (d - b);
	f -= e;
	cout << f << endl;



}


Measured memory_bytes: 3636
[n,x] = [int(i) for i in input().split()]
ls = [1]
pts = [1]

for i in range(50):
    ls.append(2 * ls[-1] + 3)
    pts.append(2 * pts[-1] + 1)

ans = 0

while n > 0 and x >= 0:
    if x < ls[n]//2:
        x -= 1
        n -= 1
    elif x == ls[n]//2:
        x = -1
        ans += pts[n-1]
    else:
        if x == ls[n]:
            x = 0
            ans += pts[n]
        else:
            x -= ls[n]//2
            ans += pts[n-1]+1
print(ans)


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


int main() {
    ll n;
    cin >> n;
    vector<ll> p(n,0);
    rep(i,n)cin >> p.at(i);
    ll ans = 0;
    rep(i,n){
        if(i != n-1 && p.at(i)-1 == i){
            swap(p.at(i),p.at(i+1));
            ans ++;
        }else if (i == n-1 && p.at(i)-1 == i)
        {
            swap(p.at(i-1),p.at(i));
            ans++;
        }   
    }
    cout << ans << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

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

    string ans = "APPROVED";
    rep(i, n){
        cin >> a;
        if(a%2==0){
            if(a%3!=0 and a%5!=0){
                ans="DENIED";
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int a;
	cin >> a;
	if (a < 100)
	{
		cout << "Bad";
		return 0;
	}
	while (a >= 10)
	{
		if (a / 10 % 10 == a % 10)
		{
			cout << "Bad";
			return 0;
		}
		a /= 10;
	}
	cout << "Good";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long llong;
const int inf = 1 << 20;
const int mod = 1e9 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) { cin >> h[i]; }
  sort(h.begin(), h.end(), greater<int>());
  llong sum = 0;
  rep(i, min(k, n)) { h[i] = 0; }
  llong ans = 0;
  rep(i, n) { ans += h[i]; }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int N;
	int cnt = 0;
	int ans = 0;
	int mn = INF;

	cin >> N;

	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		if(tmp<0){
			tmp = -tmp;
			cnt++;
		}
		mn = min(mn, tmp);
		ans += tmp;
	}

	if(cnt%2==0){
		cout << ans << endl;
	}else{
		cout << ans - mn*2 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <limits.h>
#include <cmath>
#include <time.h>
#include <cstdio>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/* ここからが本編 */
/*  */
int main(void)
{
  int test = 1;
  int i,j,k,l;
  int n;
  int min = INT_MAX;
  int rep = INT_MIN;
  int a;
  scanf("%d",&n);
  rep(i,n) {
    scanf("%d",&a);
    if(a - min > rep) rep = a - min;
    if(min > a) min = a;
  }
  printf("%d\n",rep);
  return 0;
}

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

int main(){
  int n = -1, w = -1, s = 	-1, e = -1;
  string str;
  cin >> str;
  rep(i, str.length()){
    if(str[i] == 'N') n = 1;
    if(str[i] == 'W') w = 1;
    if(str[i] == 'S') s = 1;
    if(str[i] == 'E') e = 1;
  } 
  puts(n * s == 1 && w * e == 1 ? "Yes" : "No");  
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N;
  bool ok = true;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    if (A % 2 == 0) {
      if (A % 3 != 0 && A % 5 != 0) {
        ok = false;
        break;
      }
    }
  }
  if (ok) {
    cout << "APPROVED" << endl;
  }
  else {
    cout << "DENIED" << endl;
  }  
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int D;cin>>D;
    switch(D){
        case 22:
            cout<<"Christmas Eve Eve Eve"<<endl;break;
        case 23:
            cout<<"Christmas Eve Eve"<<endl;break;
        case 24:
            cout<<"Christmas Eve"<<endl;break;
        case 25:
            cout<<"Christmas"<<endl;break;
    }
}


Measured memory_bytes: 3492
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

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

  int L = *max_element(all(a)), S = *min_element(all(a));
  //cout << L << " " << S << endl;
  bool flag = true;
  if(L-S >= 2) flag = false;
  else if(L == S+1){
    int Lcnt = 0,Scnt = 0;
    for(int i = 0; i < n; i++){
      if(a[i] == L) Lcnt++;
      else Scnt++;
    }

    if(!(Scnt < L && 2*(L-Scnt) <= Lcnt)) flag = false;
  }else if(!(L == n-1 || 2*L <= n)) flag = false;

  cout <<(flag?"Yes":"No") << endl;


  return 0;
}

Measured memory_bytes: 768
#include<stdio.h>
#define MAX 400

int S[MAX];
int top=1;

void push(int);
int pop();

int main()
{
  int i,j;
  int x,y;
  char input[MAX];

  for(i=1;i<MAX;i++){
  scanf("%c",&input[i]);
  if(input[i] == 10) break;
  }

  //printf("%s",input+1);

  for(j=1;j<i;j++){
    //数字の時
    if(input[j] >= 48 && input[j] <= 57){
      //int型に変換
      x = input[j]-48;
      while(input[j+1] >= 48 && input[j+1] <= 57){
	x = x*10;
	x += input[j+1]-48;
	j++;
      }
      push(x);
    }
    // + の時
    else if(input[j] == 43){
      y = pop();
      x = pop();
      push(x+y);
    }
    // - の時
    else if(input[j] == 45){
      y = pop();
      x = pop();
      push(x-y);
    }
    // * の時
    else if(input[j] == 42){
      y = pop();
      x = pop();
      push(x*y);
    }
  }
  
  printf("%d\n",S[1]);
  
  return 0;
}

void push(int x)
{
  S[top] = x;
  // printf("push : %d\n",S[top]);
  top++;
}

int pop()
{
  int x;
  top--;
  x = S[top];
  // printf("pop : %d\n",S[top]);
  S[top] = 0;

  return x;
  }



Measured memory_bytes: 2108
S = str(input())
a=['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']
for i in range(len(S)):
  if S[i] in a:
    a.remove(S[i])
print(None if a==[] else a[0])


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

int main() {
  ll n;
  cin >> n;
  //tupleじゃなくてpairでおｋ、書き換えるの面倒くさい
  vector<tuple<string,ll,ll>> s(n);
  rep(i,n){
    string st; ll nt;
    cin >> st >> nt;
    s.emplace_back(st,nt,i);
  }
  string p;
  cin >> p;
  
  bool flag = false;
  ll ans = 0;
  for(auto &x : s){
    //cout << get<0>(x) << endl; //string取得
    if(flag){
      ans += get<1>(x);
    }else{
      if(get<0>(x) == p) flag = true;
    }
  }
  cout << ans << endl;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    int a_min = ceil((double)a / 0.08);
    double a_max = 0.0;
    a_max = max(a_min, (int)(modf((double)(a + 1) / 0.08, &a_max) > 0.0 ? a_max : a_max - 1.0));
    int b_min = ceil((double)b / 0.10);
    double b_max = 0.0;
    b_max = max(b_min, (int)(modf((double)(b + 1) / 0.10, &b_max) > 0.0 ? b_max : b_max - 1.0));
    if((a_min == b_min) || ((a_min > b_min) && (a_min <= b_max))) cout << a_min << endl;
    else if((a_min < b_min) && (b_min <= a_max)) cout << b_min << endl;
    else cout << -1 << endl;
    return 0;
}

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

#define M 999721/* your task*/
#define NIL '\0'
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}


int h1(int key){ return key%M; }
int h2(int key){ return key%(M-1); }


//search
int find(char str[]){


  int i;
  i=0;
  long long j;

  //repeat j<-h(k,i)
  while(1){
    j=(h1(getKey(str))+i*h2(getKey(str)))%M;
    if(strcmp(str,H[j])==0) return j;
    i++;
    if(H[j][0]==NIL || i==M) return NIL;
  }
 

}

//insert
int insert(char str[]){

  int i;
  long long j;
  i=0;
  //repeatj <-h(k,i)
  while(1){
    j=(h1(getKey(str))+i*h2(getKey(str)))%M;
    if(H[j][0]==NIL){
      strcpy(H[j],str);
      return j;
    }
    else i++;
    if(i==M) break;
  }

}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

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

#define debug(x) cout << #x << " = " << x << endl

const int INF = 1<<29;
typedef long long ll;
typedef pair<int,int> P;


int main(){
   string s;
   string S = "CODEFESTIVAL2016";
   cin >> s;

   int ans = 0;
   for(int i=0; i<s.size(); i++){
	  if(s[i] != S[i]) ans++;
   }
   
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;



int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,3) cin >> a[i];
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    int res = 1<<29;
    vector<int> bit(3);
    for(bit[0] = 1; bit[0] < (1<<n); ++bit[0]){
        for(bit[1] = 1; bit[1] < (1<<n); ++bit[1]){
            if(bit[0] & bit[1]) continue;
            for(bit[2] = 1; bit[2] < (1<<n); ++bit[2]){
                if(bit[0] & bit[2]) continue;
                if(bit[1] & bit[2]) continue;
                vector<int> sums(3, 0), nums(3, 0);
                rep(i,n){
                    rep(j,3){
                        if(bit[j] & (1<<i)){
                            sums[j] += l[i];
                            nums[j]++;
                        }
                    }
                }
                int score = 0;
                rep(i,3){
                    score += abs(sums[i] - a[i]);
                    score += (nums[i] - 1) * 10;
                }
                res = min(res, score);
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = INT_MAX;

struct LazySegmentTree {
	private:
		int n;
		vector<int> node, lazy;
		vector<bool> lazyFlag;
	public:
		LazySegmentTree(vector<int> v) {
			int sz = (int)v.size();
			n = 1;
			while(n < sz) n *= 2;
			node.resize(2*n-1);
			lazy.resize(2*n-1, INF);
			lazyFlag.resize(2*n-1, false);

			for(int i=0;i<sz;i++) node[i+n-1] = v[i];
			for(int i=n-2;i>=0;i--) node[i] = min(node[2*i+1], node[2*i+2]);
		}

		void eval(int k, int l, int r) {
			if(lazyFlag[k]) {
				node[k] = lazy[k];
				// 最下層じゃないとき
				if(r - l > 1) {
					lazy[2*k+1] = lazy[2*k+2] = lazy[k];
					lazyFlag[2*k+1] = lazyFlag[2*k+2] = true;
				}
				lazyFlag[k] = false;
			}
		}

		void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
			if(r < 0) r = n;
			eval(k, l, r);
			if(b <= l || r <= a) return;
			if(a <= l && r <= b) {
				lazy[k] = x;
				lazyFlag[k] = true;
				eval(k, l, r);
			} else {
				update(a, b, x, 2*k+1, l, (l+r) >> 1);
				update(a, b, x, 2*k+2, (l+r) >> 1, r);
				node[k] = min(node[2*k+1], node[2*k+2]);
			}
		}

		int find(int a, int b, int k = 0, int l = 0, int r = -1) {
			if(r < 0) r = n;
			eval(k, l, r);
			if(b <= l || r <= a) return INF;
			if(a <= l && r <= b) return node[k];
			int vl = find(a, b, 2*k+1, l, (l+r)>>1);
			int vr = find(a, b, 2*k+2, (l+r)>>1, r);
			return min(vl, vr);
		}
};

int main() {
	int n, q;
	cin >> n >> q;
	LazySegmentTree st(vector<int>(n, INF));
	for(int i=0;i<q;i++) {
		int query;
		cin >> query;
		if(query == 0) {
			int s, t, x;
			cin >> s >> t >> x;
			st.update(s, t+1, x);
		} else {
			int s, t;
			cin >> s >> t;
			cout << st.find(s, t+1) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 5220
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int main(void) {
    vector<int> f, b;
    int i, n;
    scanf("%d",&n);
    REP (i,n) {
        int a;
        scanf("%d",&a);
        if (i % 2 == n % 2) f.push_back(a);
        else b.push_back(a);
    }
    reverse(b.begin(),b.end());
    for (auto x: b) printf("%d ",x);
    for (auto x: f) printf("%d ",x);
    puts("");
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

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

int main() {
  string S;
  cin >> S;
  REP(i, 3) {
    if (S[i] == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

bool f(ll x, vector<P>& v, ll K) {
    rep(i, v.size()) {
        int a = v[i].first, b = v[i].second;
        if ((ll)a * b <= x) continue;

        int cnt = a - (x / b);
        K -= cnt;
    }

    return K >= 0;
}

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

    vector<int> A(N);
    rep(i, N) cin >> A[i];

    vector<int> F(N);
    rep(i, N) cin >> F[i];

    sort(A.begin(), A.end());
    sort(F.begin(), F.end(), greater<int>());

    vector<P> v(N);
    rep(i, N) v[i] = P(A[i], F[i]);

    ll l = -1, r = 1e12 + 5;
    while (r - l > 1) {
        ll mid = (l + r) / 2;

        if (f(mid, v, K)) {
            r = mid;
        } else {
            l = mid;
        }
    }

    cout << r << endl;
}

Measured memory_bytes: 3328
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """

    def __init__(self, n_max, mod=10 ** 9 + 7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        if n < r:
            return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n + 1):
            fac.append(fac[i - 1] * i % self.mod)
            facinv.append(facinv[i - 1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n + 1)
        modinv[1] = 1
        for i in range(2, n + 1):
            modinv[i] = self.mod - self.mod // i * modinv[self.mod % i] % self.mod
        return modinv


def main():
    X, Y = map(int, input().split())
    if (X + Y) % 3 != 0:
        print(0)
        return
    a = (X + Y) // 3
    two = X - a
    if two < 0:
        print(0)
        return
    if two == 0:
        print(1)
        return
    cmb = Combination(a + 1)
    print(cmb(a, two))


if __name__ == "__main__":
    main()


Measured memory_bytes: 82228