akhauriyash/Code-Regression huggingface dataset:
//pragma GCC optimize("Ofast")
//pragma GCC optimize("unroint-loops")
//pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(int i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( int i = a; i >= b ; i-= k)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sz(a) (int) a.size()
#define aint(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
//#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii ;
typedef vector<int>  vi ;
typedef vector<ii> vii ;


const int MAX = 1e5+6;
const ll inf = 5e18;
ll mod=998244353;


bool is(string s){
	ll ini=0,fin=s.size()-1;
	while(ini<fin){
		if(s[ini]!=s[fin]) return false;
		ini++,fin--;
	}
	return true;
}

int main(){
	fastio;
	ll n,m;
	string s;
	cin>>s;
	n=s.size();
//	cout<<s.substr(0,n/2)<<endl;
//	cout<< s.substr  ((n+1)/2 , (n-1)/2 )<<endl;
	if(is(s) && is(s.substr(0,n/2)) && is(s.substr((n+1)/2,n/2)))
		cout<<"Yes\n";
	else cout<<"No\n";   
}

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

#define endl            "\n"
#define ll              long long
#define ld              long double 
#define ull             unsigned long long int
#define MOD             (ll)(1e9 + 7)
#define vll             vector<ll>
#define pll             pair<ll,ll>
#define mll             map<ll,ll>
#define vpll            vector<pair<ll,ll>>
#define mpll            map<pair<ll,ll>,ll>
#define len(x)          x.length()
#define all(x)          x.begin(),x.end()
#define deb1(x)         cout<<#x<<" "<<x<<endl;
#define deb2(x,y)       cout<<#x<<" "<<x<<"\t"<<#y<<" "<<y<<endl;
#define deb3(x,y,z)     cout<<#x<<" "<<x<<"\t"<<#y<<" "<<y<<"\t"<<#z<<" "<<z<<endl;
#define debug1(x)       cerr<<#x<<" "<<x<<endl;
#define debug2(x,y)     cerr<<#x<<" "<<x<<"\t"<<#y<<" "<<y<<endl;
#define debug3(x,y,z)   cerr<<#x<<" "<<x<<"\t"<<#y<<" "<<y<<"\t"<<#z<<" "<<z<<endl;
#define fr(a,b,c)       for(auto a=b;a<c;a++)
#define frc(a,b,c)      for(auto a=b;a!=c;a++)
#define pb(x)           push_back(x)
#define lb(v,x)         lower_bound(v.begin(), v.end(), x)
#define ub(v,x)         upper_bound(v.begin(), v.end(), x)
#define GR              (double)(1 + sqrt(5)) / 2
#define fib(n)          (ll)round(pow(GR,n) / sqrt(5))
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define out1(x)         cout<<x<<" "<<endl
#define out2(x,y)       cout<<x<<" "<<y<<endl
#define SORT(a)         sort(all(a));
#define ARRAY(a,n)      vll a; fr(i,0,n) { ll temp; cin>>temp; a.pb(temp); }  
#define PRINT(a)        for(auto x:a)cout<<x<<" ";cout<<endl
#define MAX             100005


template<typename T>
void output_vector(const vector<T> &v, bool debug_print=false,bool add_one = false,int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = int(v.size());
 
    for (int i = start; i < end; i++)
        (debug_print)?(cerr << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n')):(cout << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n'));
}



void solve(){
    int days;cin>>days;
    typedef vector <int> v_int;
    v_int v1(days+1),v2(days+1),v3(days+1);
    for(int i=1;i<=days;i++)
        cin>>v1[i]>>v2[i]>>v3[i];
    vector<v_int> max_ans(days+1,v_int(3,0));
    for (int i = 1; i<=days; i++)
    {
        max_ans[i][0]=v1[i]+max(max_ans[i-1][1],max_ans[i-1][2]);
        max_ans[i][1]=v2[i]+max(max_ans[i-1][0],max_ans[i-1][2]);
        max_ans[i][2]=v3[i]+max(max_ans[i-1][0],max_ans[i-1][1]);
    }
    cout<<max({max_ans[days][0],max_ans[days][1],max_ans[days][2]})<<endl;
}
int main()
{   
    // #ifndef ONLINE_JUDGE 
    //     freopen("input.txt", "r", stdin); 
    //     freopen("output.txt", "w", stdout); 
    // #endif 
    FIO;
    // ll test;cin>>test;
    // while(test--)
    solve();
    return 0;
}


Measured memory_bytes: 6912
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	public static void main(String[] args) {
		int N=sc.nextInt();
		int K=sc.nextInt();
		List<Integer> cc = new ArrayList<>(N);
		
		for(int i=0;i<N;i++) {
			cc.add(sc.nextInt());
		}
		Collections.sort(cc);
		int ans=1111111111;
		for(int i=0;i+K-1<N;i++) {
			
			ans=Math.min(cc.get(i+K-1)-cc.get(i),ans);
		}
		p(ans);
	}
	//N==S
	//E==W
//83 S 
	//69E
	//78N
	//87W
	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 61868
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
const int N=2e5+5;
#define inf 1e18+8
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define vpii vector<pair<int,int> > 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

signed  main()
{
   vi arr(N);
   int n,m;
   cin>>n>>m;
   int sum=0;
   for(int i=0;i<m;i++) 
   {
       cin>>arr[i];
       sum+=arr[i];
   }
   if((n-sum)>=0) cout<<n-sum;
   else cout<<"-1";
    
}

Measured memory_bytes: 4660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
int d=365, n=26;
int c[26];
int s[365][26];
void Main(){
    cin >> d;
    For(i,0,n) cin >> c[i];
    For(i,0,d) For(j,0,n) cin >> s[i][j];
    For(i,0,d){
        cout << (max_element(s[i],s[i]+n) - s[i]) + 1 << endl; 
    }
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

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

const int inf = 1e9;
const ll linf = 1e18;

template <ll mod> class modint
{
private:
    ll x;

public:
    modint(ll x = 0) : x(x >= 0 ? x % mod : (x % mod) + mod) {}
    modint &operator+=(const modint rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    modint &operator-=(const modint rhs) {
        if ((x += mod - rhs.x) >= mod) x -= mod;
        return *this;
    }
    modint &operator*=(const modint rhs) {
        (x *= rhs.x) %= mod;
        return *this;
    }
    modint &operator/=(const modint rhs) {
        *this *= rhs.inv();
        return *this;
    }
    modint operator+(const modint rhs) const { return modint(*this) += rhs; }
    modint operator-(const modint rhs) const { return modint(*this) -= rhs; }
    modint operator*(const modint rhs) const { return modint(*this) *= rhs; }
    modint operator/(const modint rhs) const { return modint(*this) /= rhs; }

    modint operator-() const { return modint(-x); }

    modint pow(ll n) const {
        modint e = *this, ret = modint(1);
        while (n) {
            if (n & 1) ret *= e;
            e *= e, n >>= 1;
        }
        return ret;
    }

    modint inv() const { return pow(mod - 2); }

    friend ostream &operator<<(ostream &os, const modint &m) {
        os << m.x;
        return os;
    }

    friend istream &operator>>(istream &is, modint &m) {
        ll in;
        is >> in;
        m = modint(in);
        return is;
    }
};
using mint = modint<1000000007>;

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

    int h, w; cin >> h >> w;
    vector<string> a(h);
    for (int i = 0; i < h; i++) cin >> a[i];

    mint dp[h][w];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            dp[i][j] = 0;
        }
    }

    dp[0][0] = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (i + 1 < h && a[i + 1][j] == '.') dp[i + 1][j] += dp[i][j];
            if (j + 1 < w && a[i][j + 1] == '.') dp[i][j + 1] += dp[i][j];
        }
    }

    cout << dp[h - 1][w - 1] << endl;
    return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589;

int n, q;
int p[200001];
vector<int> v[200001];
int ans[200001];

void dfs(int par, int from){
  ans[from] += p[from]+ans[par];
  for(int x: v[from]){
    if(x != par) dfs(from, x);
  }
}

int main(){
  cin >> n >> q;
  rep(i, n-1){
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  rep(i, q){
    int tmp, x;
    cin >> tmp >> x;
    p[tmp] += x;
  }
  dfs(0, 1);
  rep(i, n) cout <<ans[i+1] << " ";
  cout<<endl;
}

Measured memory_bytes: 24192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Game = vector<char>;
using Tops = map<char, int>;
const char ts[3] = {'a', 'b', 'c'};
struct Pos {
public:
    int hash;
    Game g;
    int rank;
    Pos(int h, Game g, int rank) : hash(h), g(g), rank(rank) {};
    bool is_goal() {
        char f = g[0];
        bool ok = f == 'a' || f == 'c';
        if (!ok) return false;
        for (int i=1;i<g.size();++i) {
            if (f!=g[i]) return false;
        }
        return true;
    }
    Tops get_tops() {
        Tops ts {{'a', -1}, {'b', -1}, {'c', -1}};
        for (int i = 0; i < g.size(); ++i) {
            char t = g[i];
            ts[t] = i;
        }
        return ts;
    }
};

int to_hash(Game g) {
    int v = 0;
    for (char t: g) {
        int r = ('a' == t) ? 0 : ('b' == t) ? 1 : 2;
        v = v * 3 + r;
    }
    return v;
}

void solve(int N, ll M) {
    Game game(N);
    for (int i = 0; i < 3; ++i) {
        int n;
        cin >> n;
        char t = (i == 0) ? 'a' : (i == 1) ? 'b' : 'c';
        for (int j = 0; j < n; ++j) {
            int x;
            cin >> x;
            game[x - 1] = t;
        }
    }
    vector<char> foots(3500000, 'a');
    queue<Pos> q;
    q.emplace(to_hash(game), game, 0);
    int ans = -1;
    while (!q.empty()) {
        Pos pos = q.front();
        q.pop();
        if (foots[pos.hash] != 'a') continue;
        foots[pos.hash] = 'b';
        if (pos.is_goal()) {
            if (pos.rank <= M) ans = pos.rank;
            break;
        }
        Tops tops = pos.get_tops();
        int next_rank = pos.rank + 1;
        // a -> b
        if (tops['b'] < tops['a']) {
            Game a_b = pos.g;
            a_b[tops['a']] = 'b';
            q.emplace(to_hash(a_b), a_b, next_rank);
        }
        // b -> a
        if (tops['a'] < tops['b']) {
            Game b_a = pos.g;
            b_a[tops['b']] = 'a';
            q.emplace(to_hash(b_a), b_a, next_rank);
        }
        // b -> c
        if (tops['c'] < tops['b']) {
            Game b_c = pos.g;
            b_c[tops['b']] = 'c';
            q.emplace(to_hash(b_c), b_c, next_rank);
        } else {
            Game c_b = pos.g;
            c_b[tops['c']] = 'b';
            q.emplace(to_hash(c_b), c_b, next_rank);
        }
    }
    cout << ans << endl;
}

int main() {
    int n;
    ll m;
    while(true) {
        cin >> n >> m;
        if (n == 0 && m == 0) break;
        else solve(n, m);
    }
    return 0;
}



Measured memory_bytes: 6540
# coding: utf-8

# https://atcoder.jp/contests/abc114
# 14:44-15:24 done


def soinsubunkai(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def main():
    N = int(input())

    soinsu = {}
    for i in range(2, N+1):
        i_soinsu = soinsubunkai(i)
        for p, idx in i_soinsu:
            if p not in soinsu:
                soinsu[p] = idx
            else:
                soinsu[p] += idx

    n_75, n_25, n_15, n_5, n_3 = 0, 0, 0, 0, 0
    for v in soinsu.values():
        if v >= 74:
            n_75 += 1
        if v >= 24:
            n_25 += 1
        if v >= 14:
            n_15 += 1
        if v >= 4:
            n_5 += 1
        if v >= 2:
            n_3 += 1

    n_3_5_5 = n_5 * (n_5-1) * (n_3-2) // 2
    n_5_15 = n_15 * (n_5-1)
    n_3_25 = n_25 * (n_3-1)

    return n_3_5_5 + n_5_15 + n_3_25 + n_75


print(main())


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int p; cin >> p;
	int n = p / 100;
	if (n >= 20) {
		cout << 1 << endl;
		return 0;
	}

	cout << (p <= n * 105) << endl;

	return 0;
}

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

using namespace std;

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

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 100500;

bool u[N];
int n, m, X, Y;
deque < int > dq;
vector < int > g[N];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

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

	//cout << setprecision(10) << fixed;
	
	cin >> n >> m;

	for (int i = 1; i <= m; i++) {
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
		X = x, Y = y;
	}

	u[X] = u[Y] = 1;
	dq.push_front(X);
	dq.push_front(Y);

	while (1) {
		bool found = 0;
		for (auto to : g[X]) {
			if (!u[to]) {
				u[to] = 1;
				dq.pb(to);
				X = to;
				found = 1;
				break;
			}
		}
		if (found)
			continue;
		for (auto to : g[Y]) {
			if (!u[to]) {
				u[to] = 1;
				dq.push_front(to);
				Y = to;
				found = 1;
				break;
			}
		}
		if (!found)
			break;
	}

	cout << sz(dq) << "\n";

	while (!dq.empty()) {
		cout << dq.back() << " ";
		dq.pop_back();
	}
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


Measured memory_bytes: 6784
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, D; cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D, 0));
    for (int i = 0; i < N; i++) for (int j = 0; j < D; j++) cin >> X[i][j];
    int cnt = 0; double x = 1.0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            double M = 0.0;
            for (int k = 0; k < D; ++k) {
                M += pow(X[i][k] - X[j][k], 2);
            }
            if (modf(sqrt(M), &x) == 0) cnt++;
        }
    }
    printf("%d\n", cnt);
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  vector<int> a(3); for(int i = 0; i < 3; i++) cin >> a[i];
  int cf = 0, cs = 0;
  for(int i = 0; i < 3; ++i){
    if(a[i] == 5) cf++;
    else if(a[i] == 7) cs++;
  }
  if(cf==2 && cs==1) cout << "YES" << endl;
  else cout << "NO" << endl;

  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 rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 2e9;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

class SuffixArray {
private:
    string s;
    int n;
    vector<int> rank;
    vector<int> sa;
public:
    SuffixArray(string _s) : s(_s) {
        n = s.size();
        rank.resize(n + 1);
        sa.resize(n + 1);
        construct();
    }
    void construct() {
        for (int i = 0; i <= n; ++i) {
            sa[i] = i;
            rank[i] = i < n ? s[i] : -1;
        }

        int k;
        auto compare = [&](int i, int j) {
            if (rank[i] != rank[j]) return rank[i] < rank[j];
            else {
                int ri = i + k <= n ? rank[i + k] : -1;
                int rj = j + k <= n ? rank[j + k] : -1;
                return ri < rj;
            }
        };

        vector<int> tmp(n + 1);
        for (k = 1; k <= n; k *= 2) {
            sort(sa.begin(), sa.end(), compare);

            tmp[sa[0]] = 0;
            for (int i = 1; i <= n; ++i) {
                tmp[sa[i]] = tmp[sa[i - 1]] + (compare(sa[i - 1], sa[i]) ? 1 : 0);
            }
            for (int i = 0; i <= n; ++i) {
                rank[i] = tmp[i];
            }
        }
    }
    bool contain(string t) {
        int l = 0, r = n;
        while (r - l > 1) {
            int m = (l + r) / 2;
            if (s.substr(sa[m], t.size()) < t) l = m;
            else r = m;
        }
        return s.substr(sa[r], t.size()) == t;
    }
    void print() {
        for (int i = 0; i < n; ++i) {
            cerr << s.substr(sa[i]) << endl;
        }
    }
};

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

    string s;
    cin >> s;
    SuffixArray suf(s);
    // suf.print();
    int q;
    cin >> q;
    rep(i, q) {
        string t;
        cin >> t;
        cout << suf.contain(t) << endl;
    }
}

Measured memory_bytes: 16604
// 中間試験の点数 m、期末試験の点数 f、再試験の点数 r
// 試験を受けていない場合は点数を -1
/*
	中間試験、期末試験のいずれかを欠席した場合成績は F。
	中間試験と期末試験の合計点数が 80 以上ならば成績は A 。
	中間試験と期末試験の合計点数が 65 以上 80 未満ならば成績は B。
	中間試験と期末試験の合計点数が 50 以上 65 未満ならば成績は C。
	中間試験と期末試験の合計点数が 30 以上 50 未満ならば成績は D。 ただし、再試験の点数が 50 以上ならば成績は C。
	中間試験と期末試験の合計点数が 30 未満ならば成績は F。

	m、f、r がすべて -1 のとき入力の終わりとします。

	データセットの数（生徒の数）は 50 を超えません。
*/

import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String str = null;
		String[] input = new String[3];
		int m, f, r;

		for(int i=0; i<50; i++){
			// 読み込み・変換
			str = scan.nextLine();
			input = str.split(" ");
			m = Integer.parseInt(input[0]);
			f = Integer.parseInt(input[1]);
			r = Integer.parseInt(input[2]);

			// m, f, rが全て-1のとき処理終了
			if(m == -1 && f == -1 && r == -1){
				break;
			} else if( m == -1 || f == -1 ){
				// 以下、出力
				System.out.println("F");
			}  else if( 80 <= (m + f) ){
				System.out.println("A");
			} else if( 65 <= (m + f) && (m + f) < 80){
				System.out.println("B");
			} else if( 50 <= (m + f) && (m + f) < 65){
				System.out.println("C");
			} else if( 30 <= (m + f) && (m + f) < 50 && 50 <= r){
				System.out.println("C");
			} else if( 30 <= (m + f) && (m + f) < 50 && r < 50){
				System.out.println("D");
			} else{
				System.out.println("F");
			}
		}
	}
}


Measured memory_bytes: 26220
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
using namespace std;

char st[300];

int main(){
    int n;scanf("%d",&n);
    scanf("%s",st+1);
    if (n%2){printf("No");return 0;}
    int m=n/2;
    for (int i=1;i+m<=n;++i)
    if (st[i]!=st[i+m]){
        printf("No\n");return 0;
    }
    printf("Yes\n");return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int A, B, C;
    
    printf("");
    scanf("%d %d %d", &A, &B, &C);
    
    if(1<=A&&B&&C<=20&&B<=A)
    {
        if(C-(A-B)>0)
        {
          printf("%d", C-(A-B));
        }
        else
        {
            printf("%d", 0);
        }
    }
    else
    {
        printf("error");
    }
    
    return 0;
}


Measured memory_bytes: 128
package main

import (
        "fmt"
)

func solution(a, b, n int) int {
        x := n

        if n >= b-1 {
                x = b - 1
        }

        return a * (x % b) / b
}

func main() {
        var a, b, n int
        fmt.Scan(&a, &b, &n)
        fmt.Println(solution(a, b, n))
}

Measured memory_bytes: 1752
#include <stdio.h>
#include <algorithm>

const int MAX_N = 50000;
const int MAX_M = 20;

int main(){
  // initialization
  int n,m;
  scanf("%d %d",&n,&m);
  int c[m];
  int c_max=0;
  for (auto &e: c){
    scanf("%d",&e);
    c_max = std::max(c_max,e);
  }

  // solve
  // dp
  int dp[MAX_N+c_max];
  for(auto &e: dp){e = MAX_N*2;} dp[0] = 0;
  for(int i=0;i<MAX_N;i++){
    for(auto &e: c){
      dp[i+e] = std::min(dp[i]+1,dp[i+e]);
    }
  }
  printf("%d\n",dp[n]);

}


Measured memory_bytes: 2992
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<functional>
#include <tuple>
#include <map>
#include<set>
#include <cmath>
#include <stack>
#include<cstdio>
#include<stdio.h>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<double> a(n);
	for (int i = 0;i < n;i++)cin >> a[i];
	sort(a.begin(), a.end());
	for (int i = 1;i < n;i++) {
		a[i] = (a[i] + a[i - 1]) / 2;
	}
	cout << a[n-1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


using namespace std;
using namespace __gnu_pbds;

typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<pair<int,int>, null_type,less<pair<int, int> >,rb_tree_tag,tree_order_statistics_node_update > pbds;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)

#define pb push_back
#define ft first
#define sd second
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll power(ll a, ll b) {
    ll res = 1;
    while(b) {
        if(b % 2) {
            res *= a;
        }
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll power(ll a, ll b, ll mod) {
    ll res = 1;
    a %= mod;
    while(b) {
        if(b % 2) {
            res *= a;
            res %= mod;
        }
        a = a * a % mod;
        b >>= 1;
    }
    return res % mod;
}
const int N = 1e5 + 5;
int n, k, p;
const ll mod = 998244353;

signed main() {
    int n, s;
    cin >> n >> s;
    int a[n + 4];
    memset(a, 0, sizeof a);
    ll dp[n + 4][s + 4][2];  // sum of starting index of subsequences with sum j and ending at index i;
    memset(dp, 0LL, sizeof dp);
    for(int i=1; i<=n; i++) {
        cin >> a[i];
    }
    for(int i=1; i<=n; i++) {
        for(int j=0; j<=s; j++) {
            if(j < a[i]) {
                dp[i][j][0] = dp[i-1][j][0];
            }
            else if(j == a[i]) {
                dp[i][j][0] = (dp[i-1][j][0] + i) % mod;
                dp[i][j][1] = i;
            }
            else {
                dp[i][j][0] = (dp[i-1][j][0] + dp[i-1][j-a[i]][0]) % mod;
                dp[i][j][1] = dp[i-1][j-a[i]][0];
            }
        }
    }
    ll ans = 0;
    for(int i=1; i<=n; i++) {
        if(a[i] > s) continue;
        else if(a[i] == s) {
            ans += (i * (n - i + 1)) % mod;
            ans %= mod;
        }
        else {
            ans += ((n - i + 1) * dp[i-1][s-a[i]][0]) % mod;
            ans %= mod;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 141312
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
ans += sum(B)

for i in range(N-1):
    if A[i+1] == A[i]+1:
        ans += C[A[i]-1]

print(ans)

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

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

int string_to_int(string str){
    int number = 0;
    for(int i=0;i<str.size();i++){
        int r = 1;
        for(int j=0;j<i;j++){
            r *= 4;
        }
        number += r * char_to_int(str.at(i));
    }
    return number;
}

int hash1(int num,int m){
    return num % m;
}

int hash2(int num, int m){
    return 1 + (num % (m-1));
}

int hash_(int num, int i,int m){
    int h = hash1(num,m) + i * hash2(num,m);
    return h;
}

void insert(vector<int> &array,int num,int m){
    int i = 0;
    while(true){
        int j = hash_(num,i,m);
        if(array.at(j) == 0){
            array.at(j) = num;
            break;
        }else{
            i++;
        }
    }
}

int search(vector<int> &array,int num,int m){
    int i = 0;
    while(true){
        while(true){
            int j = hash_(num,i,m);
            if(array.at(j) == num){
                return num;
            }else if(array.at(j) == 0 || i >= m){
                return 0;
                }else{
                i++;
            }
        }
    }
}



int main(){
    int m = 0,r = 1;
    for(int i=0; i<12; i++){
        r *= 4;
        m += r;
    }

    vector<int> array(m);
    int n;
    pair<string,string> order;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> order.first >> order.second;
        int num = string_to_int(order.second);
        if(order.first == "insert"){
            insert(array,num,m);
        }else{
            if(search(array,num,m)){
                cout << "yes" << endl;
            }else{
                cout << "no" << endl;
            }
        }
    }
}


Measured memory_bytes: 90040
n = int(input())
a,b,c,d = 0,0,0,0
for i in range(n):
    p = str(input())
    if p == "AC":
        a += 1
    elif p == "WA":
        b += 1
    elif p == "TLE":
        c += 1
    elif p == "RE":
        d += 1

print("AC x {}".format(a))
print("WA x {}".format(b))
print("TLE x {}".format(c))
print("RE x {}".format(d))


Measured memory_bytes: 9188
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H;
	while(cin>>N>>M) {
		VI A(N);
		REP(i, N) cin>>A[i];
		sort(ALLR(A));
		ll sum = accumulate(ALL(A), 0LL);
		VI a;
		REP(i, N) if(!(A[i]*4*M<sum)) a.PB(A[i]);
		string ans = M <= a.size() ? "Yes":"No";
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 888
N, K = map(int, input().split())
_A = list(map(int, input().split()))
A = []
ans = 0
for a in _A:
    if a >= K:  # 一つで良い集合
        ans += 1
    else:
        A.append(a)

M = len(A)
A.sort(reverse=True)
confilm = [0 for _ in range(N)]

sumA = [0 for _ in range(M + 1)]
for i in range(1, M + 1):
    sumA[i] = sumA[i - 1] + A[i - 1]

left = 0
right = 1
while right < M:
    while sumA[right] - sumA[left] >= K:
        left += 1
    for check in range(right, M):
        if (sumA[right] - sumA[left]) + A[check] >= K:
            confilm[check] = 1
            for i in range(left, right):
                confilm[i] = 1
    right += 1

ans += sum(confilm)
print(N - ans)

Measured memory_bytes: 44764
N,K=map(int,input().split())
x=list(map(int,input().split()))
ans=10**9
for i in range(N-K+1):
    tmp1=abs(x[i])+abs(x[i]-x[i+K-1])
    tmp2=abs(x[i+K-1])+abs(x[i]-x[i+K-1])
    ans=min([ans,tmp1,tmp2])
print(ans)


Measured memory_bytes: 14228
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define sz(a) int(a.size())
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
#define lson l,mid,p<<1
#define ll long long
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const double eps=1e-8;
const int mod=1e9+7;
const int N=1e5+10;
const int inf=1e9;
int a,b,c,k;
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>a>>b>>c>>k;
	int ans=0;
	int r=min(k,a);
	ans+=r;
	k-=r;
	r=min(k,b);
	k-=r;
	r=min(k,c);
	ans-=r;
	cout<<ans<<endl;
	return 0;
}

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

vector<string> M(12);
int dx[4] = {0, 1, 0, -1};
int dy[4] = {-1, 0, 1, 0};

//(x, y)にくっついえる島ぜんぶけす
void fukasa(int x, int y) {
  M[x][y] = '0';
  for(int i = 0; i < 4; i++) {
    int X = x + dx[i];
    int Y = y + dy[i];
    if(X < 0 || X >= 12 || Y < 0 || Y >= 12) { continue; }
    if(M[X][Y] == '1') { fukasa(X, Y); }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(1) {
    if(!(cin >> M[0])) { break; }
    for(int i = 1; i < 12; i++) {
      cin >> M[i];
    }
    int ans = 0;
    for(int i = 0; i < 12; i++) {
      for(int j = 0; j < 12; j++) {
        if(M[i][j] == '1') {
          fukasa(i, j);
          ans++;
          for(int i = 0; i < 12; i++) {
            // cout << M[i] << endl;
          }
          // cout << ans << endl;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


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

using namespace std;
using ll = long long;

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

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

    ll q, r;
    bool f = false;

    REP(i,1,10){
        q = N / i;
        r = N % i;
        if((r == 0) && (q < 10)){
            f = true;
        }
    }

    if(f){_PR("Yes");}
    else{_PR("No");}

    return 0;
}

/*



*/

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

int main(){
  int H,W,K;
  cin >>H>>W>>K;
  vector<string> vec(H);
  for(int i=0;i<H;i++){
    cin >> vec[i];
  }
  int ans=0;
  for(int is=0;is<(1<<H);is++){
    for(int js=0;js<(1<<W);js++){
      int cnt=0;
      for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
          if(is>>i&1){
            continue;
          }
          if(js>>j&1){
            continue;
          }
          if(vec[i][j]=='#'){
            cnt++;
          }
            
        }
      }
      if(cnt==K){
        ans++;
      }
          
    }
  }
  cout << ans <<endl;
}

      

Measured memory_bytes: 3628
N,A,B = map(int,input().split())

dif = abs(A-B)
if(dif%2 == 0):
  ans = dif//2
else:
  A1_diff = A-1
  #B1_diff = B-1
  #AN_diff = N-A
  BN_diff = N-B
  ans = min(A1_diff, BN_diff)+1+(dif-1)//2
print(ans)  

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;

class Plane{
private:
	vector< vector< int > > m_plane;
	int m_nx, m_ny;
	int m_initiation_range;
	stringstream m_ss_buf;
public:
	Plane(int nx, int ny, int init_range);//Constructor
	~Plane();//Destructor
	//「平面の中で爆弾が置かれているマス」を設定
	//int LineNo : 行番号　0-based
	//string LineString : 行番号LineNoの情報(8文字の0と1の文字列)
	void setInitialPosition(int LineNo, string &LineString);
	//初期起爆位置を入力し、起爆させる
	void Initiate(int initiation_x, int initiation_y);
	void DebugPrint();
};

Plane::Plane(int nx, int ny, int init_range){
	m_nx = nx; m_ny = ny;
	m_initiation_range = init_range;
	//配列の確保
	m_plane.resize(m_ny);
	for(int i=0; i<m_ny ;i++){
		m_plane[i].resize(m_nx);
	}
}

Plane::~Plane(){}

void Plane::setInitialPosition(int LineNo, string &LineString){
	string::iterator iterator_x;
	iterator_x = LineString.begin();
	for(int x=0;x<m_nx;x++){
		m_ss_buf<<*iterator_x;
		m_ss_buf >> m_plane[LineNo][x];
		iterator_x++;
		m_ss_buf.clear();
		m_ss_buf.str("");
	}
}

void Plane::Initiate(int initiation_x, int initiation_y){
	// Initiation code goes here...
	int xs = initiation_x - 1 - m_initiation_range;
	if(xs<0){xs=0;}
	int xe = initiation_x - 1 + m_initiation_range;
	if(xe>m_nx-1){xe = m_nx-1;}
	
	int ys = initiation_y - 1 - m_initiation_range;
	if(ys<0){ys=0;}
	int ye = initiation_y - 1 + m_initiation_range;
	if(ye>m_ny-1){ye = m_ny-1;}
	
	//[initiation_x-1][initiation_y-1]を起爆して０にする
	m_plane[initiation_y-1][initiation_x-1]=0;
	
	// cout<<"bomb = "<<initiation_x-1<<", "<<initiation_y-1<<endl;
	// cout<<"bombrange xs = "<<xs<<endl;
	// cout<<"bombrange xe = "<<xe<<endl;
	// cout<<"bombrange ys = "<<ys<<endl;
	// cout<<"bombrange ye = "<<ye<<endl;
	// this->DebugPrint();
	
	//x-direction
	for(int x = xs;x<=xe;x++){
		if(m_plane[initiation_y-1][x]==1){
			this->Initiate(x+1,initiation_y);
		}
	}
	//y-direction
	for(int y = ys;y<=ye;y++){
		if(m_plane[y][initiation_x-1]==1){
			this->Initiate(initiation_x,y+1);
		}
	}
}

void Plane::DebugPrint(){
	for(int y=0;y<m_ny;y++){
		for(int x=0;x<m_nx;x++){
			cout<<m_plane[y][x];
		}
		cout<<endl;
	}
}

int main() {
	// your code goes here
	int n_datasets = 0;
	int initiation_x, initiation_y;
	string Line;
	
	Plane plane(8, 8, 3);
	cin>>n_datasets;
	for(int d = 0;d<n_datasets;d++){
		cout<<"Data "<<d+1<<":"<<endl;
		for (int y=0;y<8;y++){
			cin>>Line;
			//cout<<"y="<<y<<",  Line="<<Line<<endl;//dubug
			plane.setInitialPosition(y, Line );
		}
		cin>>initiation_x;
		cin>>initiation_y;
		// cout<<"before initiation"<<endl;
		// plane.DebugPrint();
		plane.Initiate(initiation_x,initiation_y);
		// cout<<"after initiation"<<endl;
		plane.DebugPrint();
	}
	return 0;
}

Measured memory_bytes: 1248
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    string strs[4] = {"maerd", "remaerd", "esare", "resare"};
    for(int i=0;i<s.size();i++){
        bool flag = false;
        rep(j, 4){
            rep(k, strs[j].size()){
                if(s[i+k] != strs[j][k]) break;
                if(k == strs[j].size()-1){
                    i += strs[j].size()-1;
                    flag = true;
                }
            }
            if(flag) break;
            if(j == 3){
                cout << "NO";
                return 0;
            }
        }
    }
    cout << "YES";
}


Measured memory_bytes: 512
N = int(input())
H = list(map(int, input().split()))

dp = [0] * N
dp[1] = abs(H[1] - H[0])

for i in range(2, N):
    dp[i] = min(dp[i-2] + abs(H[i]-H[i-2]), dp[i-1] + abs(H[i] - H[i-1]))

print(dp[N-1])

Measured memory_bytes: 13928
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m;
	cin>>n>>m;
	vi in(m);
	rep(i,m)cin>>in[m-1-i];
	vi used(n);
	rep(i,m){
		int a=in[i]-1;
		if(used[a]==0){
			cout<<a+1<<endl;
			used[a]=true;
		}
	}
	rep(i,n)if(used[i]==0)cout<<i+1<<endl;
}

Measured memory_bytes: 3820
#include<bits/stdc++.h>
#define N 300005
#define LL long long
using namespace std;
int n,a[N]; LL ans;
int main()
{
	int i;
	scanf("%d",&n);
	for(i=1;i<=3*n;i++) scanf("%d",&a[i]);
	sort(a+1,a+3*n+1);
	for(i=1;i<=n;i++)
		ans+=a[3*n-2*i+1];
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1408
from collections import Counter


N = int(input())
V = list(map(int, input().split()))
V1 = []
V0 = []
for i, v in enumerate(V):
    if i % 2 == 0:
        V0.append(v)
    else:
        V1.append(v)

V1C = Counter(V1)
V0C = Counter(V0)
ans = 0

if V1C.most_common()[0][0] != V0C.most_common()[0][0]:
    ans = V1C.most_common()[0][1] + V0C.most_common()[0][1]
elif len(V1C) != 1 and len(V0C) != 1:
    ans = max(V1C.most_common()[1][1] + V0C.most_common()[0][1], V1C.most_common()[0][1] + V0C.most_common()[1][1])
elif len(V1C) != 1:
    ans = V1C.most_common()[1][1] + V0C.most_common()[0][1]
elif len(V0C) != 1:
    ans = V1C.most_common()[0][1] + V0C.most_common()[1][1]
else:
    ans = N // 2

print(N - ans)



Measured memory_bytes: 77700
//package atcoder.dpContest;

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
//        try {
//            FastScanner in = new FastScanner(new FileInputStream("src/input.in"));
//            PrintWriter out = new PrintWriter(new FileOutputStream("src/output.out"));
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        solve(1, in, out);
//        }
//        catch (IOException e) {
//            e.printStackTrace();
//        }
    }

    private static void solve(int q, FastScanner in, PrintWriter out) {
        for(int qq = 0; qq < q; qq++) {
            int n = in.nextInt();
            int[] h = new int[n];
            for(int i = 0; i < n; i++) {
                h[i] = in.nextInt();
            }
            int[] dp = new int[n];
            dp[0] = 0;
            dp[1] = Math.abs(h[1] - h[0]);
            for(int i = 2; i < n; i++) {
                dp[i] = Math.min(dp[i - 1] + Math.abs(h[i] - h[i - 1]), dp[i - 2] + Math.abs(h[i] - h[i - 2]));
            }
            out.println(dp[n - 1]);
        }
        out.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}




Measured memory_bytes: 33380