akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
typedef long long ll;
const int MOD=1e9+7;

const int MAX_N=100,MAX_K=255;

int N,K;
int A[MAX_N];

ll dp[MAX_N+1][MAX_N+1][MAX_K+1];

ll fact(int x){
	ll res=1;
	FOR(i,2,x+1){
		res*=i;
		res%=MOD;
	}
	return res;
}

int main(){
	scanf("%d %d",&N,&K);
	REP(i,N){
		scanf("%d",&A[i]);
	}
	dp[0][0][0]=1;
	FOR(i,1,N+1){
		REP(j,i+1){
			REP(k,MAX_K+1){
				dp[i][j][k]=dp[i-1][j][k];
				if (j!=0){
					dp[i][j][k]+=dp[i-1][j-1][k^A[i-1]];
				}
				dp[i][j][k]%=MOD;
			}
		}
	}
	/*
	FOR(i,1,N+1){
		REP(j,i+1){
			REP(k,MAX_K+1){
				if (dp[i][j][k]){
					fprintf(stderr,"dp[%d][%d][%d]=%lld\n",i,j,k,dp[i][j][k]);
				}
			}
		}
	}
	*/
	ll ans=0;
	FOR(i,1,N+1){
		ans+=(dp[N][i][K]*fact(i))%MOD;
		ans%=MOD;
	}
	printf("%lld\n",ans);
	return 0;
}


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

using namespace std;

const int INF = 1000;

int a[INF][INF];

int main() {
	string s; cin >> s;
	int n = int(s.size());
	int nach, kone;
	for(int i = 0;i < n;i++){
		if(s[i] == 'A'){
			nach = i;
			break;
		}
	}
	for(int i = n-1;i >= 0;i--){
		if(s[i] == 'Z'){
			kone = i;
			break;
		}
	}
	cout << kone - nach + 1;
    return 0;
}

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

using namespace std;

inline int inv(int a, int p) {
	long i = 1;
	while (a > 1) {
		int t = (p + (a >> 1)) / a;
		i = i * t%p;
		a = a * t - p;
		if (a < 0) i = p - i, a = -a;
	}
	return i;
}

int p = 1e9 + 7;
long f[111111];

int main() {
	int n, m;
	cin >> n >> m;
	f[0] = 1;
	for (int i = 0; i < n + 32; i++)
		f[i + 1] = f[i] * (i + 1) % p;
	map<int, int> a;
	for (;;) {
		int i = 2;
		for (; i*i <= m; i++)
			if (m%i == 0) goto pnz;
		if (m > 1) a[m]++;
		break;
	pnz:;
		m /= i;
		a[i]++;
	}
	long r = 1;
	for (auto t : a) {
		long b = f[t.second] * f[n - 1] % p;
		b = f[n + t.second - 1] * inv(b, p) % p;
		r = r * b%p;
	}
	cout << r << endl;
	return 0;
}


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

using namespace std;

const int64_t mod = 1e9 + 7;
const int64_t infll = (1LL << 62) - 1;
const int64_t inf = (1 << 30) - 1;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "[ ";
  for (auto a : v) os << a << " ";
  os << "]";
  return os;
}

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

  int ans = 0;
  for (int i = 0; i < S.size() / 2; i++) {
    if (S[i] != S[S.size() - i - 1]) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i > n; --i)
typedef long long ll;
#define mod 1000000007

int main() {
  int N;
  cin >> N;
  vector<ll> a(N);
  rep(i, 0, N) cin >> a[i];
  ll ans = 0;
  ll tmp = 0;
  rep(i, 0, N) {
    tmp += a[i];
    if (i % 2 == 0) {
      if (tmp <= 0) {
        ll ad = -tmp + 1;
        ans += ad;
        tmp += ad;
      }
    } else {
      if (tmp >= 0) {
        ll ds = tmp + 1;
        ans += ds;
        tmp -= ds;
      }
    }
  }
  ll ans2 = 0;
  tmp = 0;
  rep(i, 0, N) {
    tmp += a[i];
    if (i % 2) {
      if (tmp <= 0) {
        ll ad = -tmp + 1;
        ans2 += ad;
        tmp += ad;
      }
    } else {
      if (tmp >= 0) {
        ll ds = tmp + 1;
        ans2 += ds;
        tmp -= ds;
      }
    }
  }
  cout << min(ans, ans2) << endl;
  return 0;
}


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int N;
    cin >> N;

    vector<int> A(N);
    int neven = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] % 2 == 0) {
            neven++;
        }
    }

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] % 2 == 0) {
            if (A[i] % 3 == 0 || A[i] % 5 == 0) {
                cnt++;
            }
        }
    }

    if (cnt == neven) {
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil

def solve():
    n, a, b = MI()
    # a -= 1
    # b -= 1

    left = max(a-1, b-1)
    right = max(n-a, n-b)

    center = INF
    sa = abs(b - a)
    if a % 2 == b % 2:
        center = sa // 2
    else:
        t = min(a-1, n-b)
        center = t + (sa-1) // 2 + 1
    # print(left, right, center)
    print(min([left, right, center]))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl

//毎回変える場所
#define N_MAX 100


//問題文のとおり
int N,P;
int A[N_MAX];

//関数
LL combination(int n, int m) {
	//答え無し
	if(n<m || m<0)return 0;
	LL c=1;
	m=(n-m <m ? n-m:m);
	for (int ns = n - m + 1, ms = 1; ms <= m; ns++, ms++) {
		c*=ns;
		c/=ms;
	}
	return c;
}


int main() {
	//入力
	cin>>N>>P;
	REP(i,N)cin>>A[i];

	//計算
	int odd=0;
	int even=0;
	REP(i, N) {
		if(A[i]%2)odd++;
		else      even++;
	}
	//答えの場合の数
	LL ans=0;

	//ビスケットの枚数
	REP(bisket, N+1) {
		//oddの組数
		REP(oddPair, bisket / 2 + 1) {
			//oddとevenの枚数的に可能なら動く
			if (2 * oddPair+P <= odd && bisket - 2 * oddPair-P<=even) {
				ans+= combination(odd, 2 * oddPair + P)*combination(even, bisket - 2 * oddPair - P);
				/*
				int temp=combination(odd,2*oddPair+P)*combination(even,bisket-2*oddPair-P);
				cout<<odd<<" C"<<2*oddPair+P<<" * "<<even<<" C "<<bisket-2*oddPair-P<<"  "<<temp<<endl;
				cout<<"what!?"<<bisket<<endl;
				*/
			}
		}
		
	}
	cout<<ans<<endl;
	cin>>N;
	return 0;
}

Measured memory_bytes: 256
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 998244353
#define INIT -1

long long int result[3010][3010] = {};

int main() {
	int n, s;
	cin >> n >> s;
	int a[3010];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	result[0][0] = 2;
	result[0][a[0]] = 1;
	for (int i = 0; i < n - 1; i++) {
		for (int j = 0; j <= s; j++) {
			result[i + 1][j] += (result[i][j] * 2) % MOD;
			result[i + 1][j] %= MOD;
			if (j + a[i + 1] <= s) {
				result[i + 1][j + a[i + 1]] += result[i][j];
				result[i + 1][j + a[i + 1]] %= MOD;
			}
			// cout << i << " " << j << " " << result[i][j] << endl;
		}
	}
	cout << result[n - 1][s] << endl;
}

Measured memory_bytes: 74076
#include<cstdio>
#include<queue>
#include<vector>
#include<utility>

const int INF=999999999;

typedef std::pair<int,int> path_t;//first->node second->cost

struct nodes{
		int cost,num;
		std::vector<path_t> path;
		bool visited=false;
};
bool operator>(const nodes& node_a,const nodes& node_b){
		return node_a.cost>node_b.cost;
}
std::priority_queue<nodes,std::vector<nodes>,std::greater<nodes> > pq;

int v,e,r;
nodes node[100000];

void initialize(void){
	for(int lp=0;lp<100000;lp++){
		node[lp].cost=INF;
		node[lp].num=lp;
	}
}

void input(void){
	int s,t,d;
	scanf("%d%d%d",&v,&e,&r);
	for(int lp=0;lp<e;lp++){
		scanf("%d%d%d",&s,&t,&d);
		node[s].path.push_back(std::make_pair(t,d));
	}
}
void solve(void){
	node[r].cost=0;
	node[r].visited=true;
	pq.push(node[r]);
	while(!pq.empty()){
		nodes node_now=pq.top();
		pq.pop();
		for(int lp=0;lp<(int)node_now.path.size();lp++){
			int nextcost=node_now.path[lp].second+node_now.cost;
			int nextnode=node_now.path[lp].first;
			//printf("nownode:%d nowcost:%d nextnode:%d nextcost:%d\n",node_now.num,node_now.cost,nextnode,nextcost);
			if(node[nextnode].visited==false && nextcost<node[nextnode].cost){
				node[nextnode].cost=nextcost;
				pq.push(node[nextnode]);
			}
		}
	}
}

void output(void){
	for(int lp=0;lp<v;lp++){
		if(node[lp].cost==INF){
			printf("INF\n");
		}else{
			printf("%d\n",node[lp].cost);
		}
	}
}

int main(void){
	initialize();
	input();
	solve();
	output();
	return 0;
}




Measured memory_bytes: 25508
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<vector<int>> G(N);
	for (auto i = 0; i < M; ++i)
	{
		int A, B;
		cin >> A >> B;
		--A;
		--B;
		G[A].push_back(B);
		G[B].push_back(A);
	}

	auto even = 0;
	vector<int> list(N, -1);
	queue<pair<int, bool>> q;
	q.push({ 0, false });
	vector<bool> used(N);
	bool all = false;
	used[0] = true;
	while (!q.empty())
	{
		auto p = q.front();
		q.pop();
		if (p.second)
		{
			++even;
			list[p.first] = 1;
		}
		else
		{
			list[p.first] = 0;
		}

		for (auto v : G[p.first])
		{
			if (list[v] >= 0 && list[p.first] == list[v])
			{
				all = true;
				break;
			}

			if (used[v])
			{
				continue;
			}

			used[v] = true;
			q.push({ v, !p.second });
		}

		if (all)
		{
			break;
		}
	}

	auto result = 0ll;
	if (all)
	{
		result = (ll)N * (N - 1) / 2 - M;
	}
	else
	{
		for (auto i = 0; i < N; ++i)
		{
			auto num = even;
			if (list[i])
			{
				num = N - num;
			}
			num -= G[i].size();
			result += num;
		}

		result /= 2;
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 6272
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define inf (int)(1e18)

signed main(){
	int N, i, j, maxa = -inf, then_i, b;
	scanf("%lld", &N);
	int *a = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &a[i]);
		if(a[i] > maxa){
			maxa = a[i];
			then_i = i;
		}
	}
	if(maxa < 0){
		printf("%lld\n", maxa);
		printf("%lld\n", N - 1);
		for(i = N; i > then_i + 1; i--){
			printf("%lld\n", i);
		}
		for(i = 1; i <= then_i; i++){
			printf("1\n");
		}
	}
	else{
		int *ans = (int *)malloc(sizeof(int) * N);
		int even_max = 0, odd_max = 0, k = 0;
		for(i = 0; i < N; i++){
			if(i % 2 == 0){
				if(a[i] >= 0){
					even_max += a[i];
				}
			}
			else{
				if(a[i] >= 0){
					odd_max += a[i];
				}
			}
		}
		if(even_max >= odd_max){
			printf("%lld\n", even_max);
			b = 0;
			for(i = 0; i < N; ){
				if(i % 2 == b && a[i] >= 0){
					break;
				}
				else{
					ans[k] = 1;
					k++;
					for(j = 1; j < N; j++){
						a[j - 1] = a[j];
					}
					N--;
					b = 1 - b;
				}
			}
			for(i = N - 1; i >= 0; i--){
				if(i % 2 == b && a[i] >= 0){
					break;
				}
				else{
					ans[k] = i + 1;
					k++;
					N--;
				}
			}
			for(i = 1; i < N; ){
				if(a[i - 1] >= 0 && a[i + 1] >= 0){
					ans[k] = 2;
					k++;
					a[0] += a[2];
					for(j = 3; j < N; j++){
						a[j - 2] = a[j];
					}
					N -= 2;
				}
				else{
					ans[k] = 3;
					k++;
					a[1] += a[3];
					for(j = 4; j < N; j++){
						a[j - 2] = a[j];
					}
					N -= 2;
				}
			}
		}
		else{
			printf("%lld\n", odd_max);
			b = 1;
			for(i = 0; i < N; ){
//				printf("b = %lld\n", b);
//				printf("a[%lld] = %lld\n", i, a[i]);
				if(i % 2 == b && a[i] >= 0){
					break;
				}
				else{
					ans[k] = 1;
					k++;
					for(j = 1; j < N; j++){
						a[j - 1] = a[j];
					}
					N--;
					b = 1 - b;
				}
			}
			for(i = N - 1; i >= 0; i--){
				if(i % 2 == b && a[i] >= 0){
					break;
				}
				else{
					ans[k] = i + 1;
					k++;
					N--;
				}
			}
			for(i = 1; i < N; ){
				if(a[i - 1] >= 0 && a[i + 1] >= 0){
					ans[k] = 2;
					k++;
					a[0] += a[2];
					for(j = 3; j < N; j++){
						a[j - 2] = a[j];
					}
					N -= 2;
				}
				else{
					ans[k] = 3;
					k++;
					a[1] += a[3];
					for(j = 4; j < N; j++){
						a[j - 2] = a[j];
					}
					N -= 2;
				}
			}
		}
		printf("%lld\n", k);
		for(i = 0; i < k; i++){
			printf("%lld\n", ans[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
struct union_find_tree1{
    vector<int> par;//0-indexed
    union_find_tree1(int sz){ //コンストラクタ
        par.resize(sz); //サイズをszに変更
        for(int i=0;i<sz;++i) par[i] = i; //最初は自分が根
    }
    int find(int a){
        if(a==par[a]) return a;
        return find(par[a]);         //引数aの根が計算されたのでそれを返す。
    }
    void unite(int a,int b){
        int root_a = find(a),root_b = find(b);  //aの根,bの根を調べて代入。
        par[root_a] = root_b;       //根aの親をbにする
    }
    bool same(int a,int b){  //aとbが同じ集合なら1,違うなら0
        return find(a)==find(b);
    }
};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,q;
  cin >> n >> q;
  union_find_tree1 uf(n);
  REP(i,q){
    int com,x,y;
    cin >> com >> x >> y;
    if(com==0){
      uf.unite(x,y);
    }else{
      cout << uf.same(x,y) << endl;
    }
  }
}




Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	long long n, d, x, y;
	cin >> n >> d;
	int cnt = 0;
	while(n--)
	{
		cin >> x >> y;
		if(sqrt(x * x + y * y) <= d)
			cnt++;
	}
	cout << cnt ;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}

Measured memory_bytes: 3572
S = list(input())
ans = 0
for i in range(len(S)):
    res = 0
    for j in range(i, len(S)):
        if S[j] in ["A", "T", "G", "C"]:
            res += 1
        else:
            ans = max(ans, res)
            break
    else:
        ans = max(ans, res)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
class Range {
    using T = long long;
    class Iterator {
        T val, step, diff;
    public:
        Iterator(T v, T s, T d): val(v), step(s), diff(d) {}
        T operator*() { return val + diff; }
        bool operator!=(const Iterator &itr) { return step > 0 ? val < itr.val : val > itr.val; }
        Iterator operator++() { val += step; return *this; }
    };
    Iterator _begin, _end;
public:
    Range(T b, T e, T s, T d): _begin(b, s, d), _end(e, s, d) {
        if (s < 0) { _begin = Iterator(e - 1, s, d); _end = Iterator(b - 1, s, d); }
    }
    Range(T b, T e, T s): Range(b, e, s, 0) {}
    Range(T b, T e): Range(b, e, 1, 0) {}
    Range(T e): Range(0, e, 1, 0) {}
    Iterator begin() { return _begin; }
    Iterator end() { return _end; }
};
// clang-format on

#include <map>
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::int128_t;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int t;
    cin, t;
    REP(_, 0, t) {
        ll n;
        int128_t abc[3], d;
        cin, n, abc[0], abc[1], abc[2], d;
        map<ll, int128_t> memo;
        const int mul[3] = {2, 3, 5};

        function<int128_t(ll)> func = [&](ll num) {
            if (memo.count(num)) {
                return memo[num];
            }
            if (num <= 1) {
                return d * num;
            }
            int128_t res = num * d;
            REP(k, 0, 3) {
                ll m = mul[k];
                if (num % m == 0) {
                    chmin(res, func(num / m) + abc[k]);
                } else {
                    chmin(res, func(num / m) + abc[k] + (num - num / m * m) * d);
                    chmin(res, func(num / m + 1) + abc[k] + ((num / m + 1) * m - num) * d);
                }
            }
            return memo[num] = res;
        };
        print(func(n));
    }
    return 0;
}


Measured memory_bytes: 4816
#include <bits/stdc++.h>
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define f first
#define s second
using namespace std;
int main() {
    IO;
    int n;
    cin >> n;
    int arr[n];
    int dp[3];
    for(int i = 0; i < n; ++i)
        cin >> arr[i];
    dp[0] = 0;
    dp[1] =  abs(arr[1]-arr[0]);
    int itr = 2;
    for(int i = 2; i < n; ++i){
        dp[itr] = min(abs(arr[i]-arr[i-2])+dp[(itr+1)%3], abs(arr[i]-arr[i-1])+dp[(itr+2)%3]);
        itr = (itr+1)%3;
    }
    cout << dp[(itr+2)%3];
    return 0;
}


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

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

    vector<vector<int>> a;
    vector<int> c;
    vector<int> mmmm;

    for(int i = 0; i < n; ++i)
    {
        int ctmp;
        cin >> ctmp;
        c.push_back(ctmp);
        vector<int> tttmp;
        for(int j = 0; j < m; ++j)
        {
            int tmp;
            cin >> tmp;
            tttmp.push_back(tmp);
        }
        a.push_back(tttmp);
    }

    for (int bit = 0; bit <= pow(2,n); ++bit) 
    {
        vector<int> sumer(m,0);
        int sm = 0;
        for(int i=0; i < n; ++i)
        {
            if (bit & (1 << i)) {
                for(int j = 0; j < m; ++j)
                {
                    sumer.at(j) += a.at(i).at(j);
                }
                sm += c.at(i);
            }
        }
        bool check = true;
        for(int j=0; j < m; ++j)
        {
            if(sumer.at(j) < x) check = false;
        }
        if(check) mmmm.push_back(sm);
    }

    if(mmmm.size() > 0)
    {
        std::vector<int>::iterator iter = std::min_element(mmmm.begin(), mmmm.end());
        cout << *iter << endl;
    }
    else
    {
        cout << -1 << endl;
    }
    

    return 0;
}



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

int main()
{
	int n;
	cin>>n;
	bool p=true;
	for(int i=0;i<n;i++)
	{
		int q;
		cin>>q;
		if(q%2 == 0)
		{
			if((q%3 != 0) && (q%5 != 0))
			{
				p=false;	
			}
		}
	}
	if(p)
	{
		cout<<"APPROVED";
	}
	else{
		cout<<"DENIED";
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  int count = 0;
  int a;
  for (int i=0;i<n; i++) {
    cin >>a;
    if(a % 2) 
      count++;
  }
  
  if (count % 2) {
    cout<<"NO";
  } else {
    cout<<"YES";
  }
 return 0;
}


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

int main() {
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> uf(2 * N), sz(2 * N);
    iota(uf.begin(), uf.end(), 0UL);
    fill(sz.begin(), sz.begin() + N, 1UL);
    const auto& find = [&uf](unsigned long i) -> unsigned long {
        while(i != uf[i])i = uf[i] = uf[uf[i]];
        return i;
    };
    const auto& unite = [&uf, &sz, &find](unsigned long i, unsigned long j) -> void {
        i = find(i);
        j = find(j);
        if(i == j)return ;
        if(sz[i] < sz[j])swap(i, j);
        sz[i] += sz[j];
        uf[j] = i;
    };
    const auto& add_edge = [&N, &unite](unsigned long i, unsigned long j) -> void { unite(i, j + N); unite(i + N, j); };
    for(unsigned long i{1}, a, b; i < N; ++i){
        cin >> a >> b;
        add_edge(--a, --b);
    }
    const auto& two_color = [&find](unsigned long i) -> unsigned long { return find(i) == find(0); };
    deque<unsigned long> a;
    if(sz[find(0)] * 3 <= N){
        for(unsigned long i{1}; i * 3 <= N; ++i)a.push_back(3 * i);
        for(unsigned long i{0}; i * 3 + 1 <= N; ++i)a.push_back(3 * i + 1);
        for(unsigned long i{0}; i * 3 + 2 <= N; ++i)a.push_back(3 * i + 2);
    }else if(sz[find(N)] * 3 <= N){
        for(unsigned long i{0}; i * 3 + 1 <= N; ++i)a.push_back(3 * i + 1);
        for(unsigned long i{0}; i * 3 + 2 <= N; ++i)a.push_back(3 * i + 2);
        for(unsigned long i{1}; i * 3 <= N; ++i)a.push_back(3 * i);
    }else{
        for(unsigned long i{0}; i * 3 + 1 <= N; ++i)a.push_back(3 * i + 1);
        for(unsigned long i{1}; i * 3 <= N; ++i)a.push_back(3 * i);
        for(unsigned long i{0}; i * 3 + 2 <= N; ++i)a.push_back(3 * i + 2);
    }
    for(unsigned long i{0}; i < N; ++i)if(two_color(i)){
        cout << a.front() << " ";
        a.pop_front();
    }else{
        cout << a.back() << " ";
        a.pop_back();
    }
    return 0;
}

Measured memory_bytes: 8948
#include<bits/stdc++.h>
#define reg(i,a,b) for(int i=a;i<=b;i++)
#define reh(i,a,b) for(int i=a;i>b;i--)
#define in(x) scanf("%d",&x)
#define fro freopen("D:\\testdata.in", "r", stdin)
#define il inline
#define lson(q) q<<1
#define rson(q) q<<1|1
using namespace std;
typedef long long ll;
const int mx=1e5+10;
int a[mx];
int b[mx];
int n,m;
int res;
int main(){
	cin>>n;
	reg(i,1,n){
		cin>>a[i];
	}
	reg(i,1,n){
		reg(j,i+1,n){
			res+=a[i]*a[j];
		}
	}
	cout<<res<<endl;
	return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n;
	cin>>n;
	vii g(n,vi(n,0));
	FOR(i,0,n){
		string s;
		cin>>s;
		FOR(j,0,n){
			if(s[j]=='1'){
				g[i][j]=1;
			}
		}
	}
	int ans=-1;
	FOR(t,0,n){
		int mx=1;
		int dep[222]={};
		queue<int> q;
		dep[t]=1;
		q.push(t);
		while (q.size()) {
			int nw=q.front();
			q.pop();
			//cerr<<nw<<endl;
			FOR(i,0,n){
				if(g[nw][i]){
					if(dep[i]==0){
						dep[i]=dep[nw]+1;
						mx=max(dep[i],mx);
						q.push(i);
					}
				}
			}
		}
		FOR(i,0,n){
			FOR(j,0,n){
				if(g[i][j]){
					if(abs(dep[i]-dep[j])==1){

					}else{
						mx=-1;
					}
				}
			}
		}
		ans=max(mx,ans);
	}

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


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>


int main()
{
    std::cout << std::fixed << std::setprecision(10);
    int n; std::cin >> n;
    long double ans = 0.0;
    for(int i=0; i<n; i++)
    {
        long double x; std::string u;
        std::cin >> x >> u;
        if(u=="JPY")
        {
            ans += x;
        }
        else
        {
            ans += 380000 * x;
        }   
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#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()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll N;
    cin >> N;
    if(N % 2) {
        cout << 0 << endl;
    } else {
        ll num = 10;
        ll res = 0;
        while(num <= N) {
            res += N / num;
            num *= 5;
        }
        cout << res << endl;
    }
    return 0;
}

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

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var amida = Enumerable.Range(1, n).ToArray();
        var m = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < m; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(',');
            var a = int.Parse(line[0])-1;
            var b = int.Parse(line[1])-1;
            amida = Change(amida, a, b);
        }
        foreach (var x in amida)
            Console.WriteLine(x);
    }
    public static int[]  Change (int[] a ,int x, int y)
    {
        var buf = a[x];
        a[x] = a[y];
        a[y] = buf;
        return a;
    }
}

Measured memory_bytes: 9408
// In the Name of Allah. Ya Ali!
#include<bits/stdc++.h>
#define bp __builtin_popcount
typedef long long ll;
const ll MAX_N = 30;
const ll MOD = 1e9+7;
using namespace std;

int mat[MAX_N][MAX_N];
vector<int> vc[MAX_N];
int dp[MAX_N][1 << 21];
int n;

int main()
{
    cin >> n;
    for(int i = 1;i<=n;++i)
        for(int j = 1;j<=n;++j)
            cin >> mat[i][j];
    for(int i = 1;i<(1 << n);++i)
        vc[bp(i)].push_back(i);
    dp[0][0] = 1;
    for(int i = 1;i<=n;++i)
    {
        for(int j = 1;j<=n;++j)
        {
            if (!mat[i][j])
                continue;
            for(auto mask:vc[i])
            {
                if (mat[i][j] and (mask & (1<<(j-1))))
                    dp[i][mask] += dp[i-1][mask-(1<<(j-1))];
                dp[i][mask] %= MOD;
            }
        }
    }
    cout << dp[n][(1 << n) -1];
    return 0;
}


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

int n, m;
int a[1020], b[1020];
int vote[1020];

int main()
{
    while(cin >> n>> m)
    {
        memset(vote, 0, sizeof vote);
        for(int i=1;i<=n;i++) scanf("%d",&a[i]);
        for(int i=1;i<=m;i++) scanf("%d",&b[i]);

        for(int i=1;i<=m;i++)
        {
            int j = 1;
            while(a[j] > b[i]) j++;
            vote[j]++;
        }
        printf("%d\n",max_element(vote+1,vote+n+1)-vote);
    }
    return 0;
}

Measured memory_bytes: 1236
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC155B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var a = Console.ReadLine().Split().Select(int.Parse).ToList();

            bool check = Program.check(a);
            
            Console.WriteLine(check ? "APPROVED" : "DENIED");

        }

        private static bool check(List<int> list)
        {
            var evenlist = list.Where(x =>x % 2 == 0).ToList();

            var b = evenlist.Select(x => x % 3 == 0 || x % 5 == 0).ToList();

            if (b.Contains(false))
            {
                return false;
            }

            return true;
        }
    }
}

Measured memory_bytes: 28636
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.*;
public class Main {

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        while(true)
        {
            int n = sc.nextInt();
            int r =sc.nextInt();
            if(n==0&&r==0)return;
            List<Integer> data = new ArrayList<>();
            IntStream.rangeClosed(1, n).forEach(i -> data.add(i));
            for(int i=0;i<r;i++)
            {
                int p = sc.nextInt();
                int c = sc.nextInt();
                int from = n - p - c+1;
                int to = from + c;
                List<Integer> range = new ArrayList<>();
                range.addAll(data.subList(from,to));
                for(int f=0;f<c;f++)data.remove(from);
                data.addAll(range);
            }
            System.out.println(data.get(n-1));
        }
    }
}

Measured memory_bytes: 40584
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007

int main(){
    int n,m,t=0;
    cin>>n>>m;
    int a[n];
    rep(i,0,n){
        cin>>a[i];
        t+=a[i];
    }
    sort(a,a+n,greater<int>());
    bool f=true;
    rep(i,0,m){
        if(4*m*a[i]<t){
            f=false;
            break;
        }
    }
    if(f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = getInt(sc);
		int b = getInt(sc);
		int c = getInt(sc);

		int count = 0;
		while (true) {
			if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
				System.out.println(count);
				break;
			}
			int nextA = b / 2 + c / 2;
			int nextB = a / 2 + c / 2;
			int nextC = a / 2 + b / 2;

			// 操作をしても変わらない場合無限
			if (a == nextA && b == nextB && c == nextC) {
				System.out.println(-1);
				break;
			} else {
				a = nextA;
				b = nextB;
				c = nextC;
				count++;
			}
		}

	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    int anime = a % 2 + b % 2 + c % 2, ans = 0;

    if (anime == 1) {
        ans++;
        if (a % 2 == 0)
            a++;
        if (b % 2 == 0)
            b++;
        if (c % 2 == 0)
            c++;
    }
    else if (anime == 2) {
        ans++;
        if (a % 2)
            a++;
        if (b % 2)
            b++;
        if (c % 2)
            c++;
    }

    int mx = max(max(a, b), c);

    ans += (mx * 3 - a - b - c) / 2;

    cout << ans << "\n";
 
    return 0;
}

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

#define int long long
#define w cout
#define e '\n'
#define sz(x) (int)x.size()
template<class T, class U> inline istream& operator>>(istream& str, pair<T, U> &p) { return str >> p.first >> p.second; }
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

const int N = 1e6 + 10 , mod = 998244353;

signed main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int h , n; cin >> h >> n;
	int val[n] , wt[n];
	for(int i = 0; i < n ;i ++) {
		cin >> val[i] >> wt[i];
	}
	int dd[h+1] = {};
	for(int i = 1 ;i <= h; i ++) dd[i] = 1e15;
	
	for(int i = 1 ;i <= h; i ++) {
		for(int j = 0 ; j < n ;j ++ ){
			int pos = max(0ll , i - val[j]);
			dd[i] = min(dd[i] , dd[pos] + wt[j]);
		}
	}
	w << dd[h];
	
}	



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

int n;
string s;
int cnt[5];

int main(){
	cin >> n;
	rep(i, n){
		cin >> s;
		if(s == "AC") cnt[0]++;
		if(s == "WA") cnt[1]++;
		if(s == "TLE")cnt[2]++;
		if(s == "RE") cnt[3]++;
	}
	cout << "AC x " << cnt[0] << endl;
	cout << "WA x " << cnt[1] << endl;
	cout << "TLE x " << cnt[2] << endl;
	cout << "RE x " << cnt[3] << endl;
	return 0;
} 

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();

		for (int i = a; i <= b; i++) {
			if (i <= (a + k - 1) || (b - k + 1) <=  i) {
				System.out.println(i);	
			}
		}

		sc.close();
	}
}


Measured memory_bytes: 22740
n = int(input())
s = input()

r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')

ans = r_cnt * g_cnt * b_cnt

for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1

print(ans)

Measured memory_bytes: 9208
import collections

n, m, k = map(int, input().split())
ab = [[] for i in range(n + 1)]
cd = [[] for i in range(n + 1)]
for i in range(m):
    a, b = map(int, input().split())
    ab[a].append(b)
    ab[b].append(a)
for i in range(k):
    c, d = map(int, input().split())
    cd[c].append(d)
    cd[d].append(c)
flag = [False for i in range(n + 1)]
groups = []
num = 1
while num <= n:
    if flag[num] == True:
        num += 1
        continue
    else:
        temp = set()
        queue = collections.deque([num])
        while queue:
            temp2 = queue.popleft()
            temp |= {temp2}
            flag[temp2] = True
            for i in ab[temp2]:
                if i not in temp:
                    queue.append(i)
        groups.append(temp)
group = [None for i in range(n + 1)]
for i in range(len(groups)):
    for j in groups[i]:
        group[j] = i
for i in range(1, n + 1):
    temp = groups[group[i]]
    temp2 = temp & set(cd[i])
    temp3 = temp & set(ab[i])
    print(len(temp) - 1 - len(temp2) - len(temp3), end = " ")

Measured memory_bytes: 146248
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
string s;
int main() {
	cin >> s;
	cout << s.substr(0, 5) << ' ' << s.substr(6, 7) << ' ' << s.substr(14, 5) << endl;
	return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
n, w = map(int, input().split())
weight = [0]*n
value = [0]*n
dp = [[0 for i in range(w+1)] for i in range(n+1)]
for i in range(n):
    weight[i], value[i] = map(int, input().split())

for i in range(n):
    for j  in range(w+1):
        if j - weight[i] >= 0:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j - weight[i]] + value[i])
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])

print(dp[n][w])


Measured memory_bytes: 171912
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

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

	vector<int> buttonStream(N);

	for ( int i = 0 ; i < N ; i++ ) {
		cin >> a;
		buttonStream.at(i) = a - 1;
	}

	int now = 0, c = 0;

	for ( ; ; ){
		if ( now == 1) {
			cout << c << endl;
			break;
		}

		if (c >= N ) {
			cout << -1 << endl;
			break;
		}

		c++;
		now = buttonStream.at(now);
	}
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
#define ll long long



int main()
{
    ll h,w;
    cin>>h>>w;
    char l1[h+1][w+1];
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>l1[i][j];
        }
    }
    for(int i=1;i<=w+2;i++)cout<<'#';
    cout<<endl;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(j==1)cout<<'#';
            cout<<l1[i][j];
            if(j==w)cout<<'#';
        }
        cout<<endl;
    }
    for(int i=1;i<=w+2;i++)cout<<'#';
    cout<<endl;
}


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

int main(void) {
    int k, a, b;
    cin >> k >> a >> b;
    
    for (int i = 0; (i * k) <= b; i++) {
        if ( a <= (i * k) && (i * k) <= b) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include <cstdio>
#include<cstring>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
int main()
{
	int S;
	int a, c;
	cin >> S;
	a = S / 100;
	c = S % 100;
	if (a <= 12 && a >= 1 && c <= 12 && c >= 1) { cout << "AMBIGUOUS" << endl; }
	else if (a <= 12 && (c > 12 ||c >= 0)&&a > 0 ) { cout << "MMYY" << endl; }
	else if ((a > 12 || a == 0) && c <= 12 && c > 0) { cout << "YYMM" << endl; }
	else { cout << "NA" << endl; }

	return 0;
}

Measured memory_bytes: 256
//
//  main.c
//  2525
//
//  Created by x15071xx on 2016/12/17.
//  Copyright © 2016年 AIT. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {

        int a,b;
        char op;
        scanf("%d %c %d",&a,&op,&b);
        
        if(op == '-'){
            printf("%d\n",a-b);
        } else {
            printf("%d\n",a+b);
        }
    
    return 0;
}

Measured memory_bytes: 128
use std::collections::HashMap;

fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let s = read1::<String>().chars().collect::<Vec<char>>();
    let mut dict = HashMap::new();

    for &c in s.iter() {
        let count = dict.entry(c).or_insert(0);
        *count += 1;
    }
    match dict.get(&'0') {
        Some(n) => {
            match dict.get(&'1') {
                Some(m) => {
                    println!("{}", std::cmp::min(n, m) * 2);
                }
                _ => {
                    println!("0");
                }
            };
        }
        _ => {
            println!("0");
        }
    };
}

Measured memory_bytes: 4352
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const long long INF = 1LL << 60;
using namespace std;

template<class T> inline void chmin(T& a, T b) { if (a > b) a = b; }
template<class T> inline void chmax(T& a, T b) { if (a < b) a = b; }

int main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n)cin>>a[i];

    long long dp[n];
    rep(i,n)dp[i] = INF;

    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);
    for(int i=2;i<n;++i){
        chmin(dp[i],dp[i-1] + abs(a[i]-a[i-1]));
        chmin(dp[i],dp[i-2] + abs(a[i]-a[i-2]));
    }

    cout<<dp[n-1];
}

Measured memory_bytes: 1408
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import copy

def rdp_connect() -> bool:
    global n, m, c
    n, m = map(int, input().split())
    if n == m == 0:
        return False
    c = [list(input()) for _ in range(n)]
    return True

def rdp_check() -> bool:
    DY = (0, 1,  0, -1)
    DX = (1, 0, -1,  0)
    def refresh(d: int, x1: int, y1: int, x2: int, y2: int) -> bool:
        global c
        st = copy.deepcopy(c)
        y, x = y1, x1
        flag = True
        while flag or not ((y, x) == (y1, x1) or (y, x) == (y2, x2)):
            st[y][x] = '#'
            for _ in range(4):
                fy, fx = y + DY[d], x + DX[d]
                ly, lx = y + DY[(d + 3) % 4], x + DX[(d + 3) % 4]
                if 0 <= ly < n and 0 <= lx < m and c[ly][lx] == '.':
                    y, x = ly, lx
                    d = (d + 3) % 4
                    flag = False
                    break
                elif 0 <= fy < n and 0 <= fx < m and c[fy][fx] == '.':
                    y, x = fy, fx
                    flag = False
                    break
                d = (d + 1) % 4
            if flag:
                return d, False
        st[y1][x1] = '.'
        c = st
        return d, (y, x) == (y2, x2)
    d, flag = refresh(0, 0, 0, m - 1, 0)
    if not flag:
        return False
    d, flag = refresh(d, m - 1, 0, m - 1, n - 1)
    if not flag:
        return False
    d, flag = refresh(d, m - 1, n - 1, 0, n - 1)
    if not flag:
        return False
    return refresh(d, 0, n - 1, 0, 0)[1]

if __name__ == '__main__':
    while rdp_connect():
        if rdp_check():
            print('YES')
        else:
            print('NO')

Measured memory_bytes: 8132
#!/usr/bin/env python3
import sys
import math


def solve(N: int, K: int):
    ans = 0.0
    for i in range(1, N+1):
        n = math.ceil(math.log2(K/i))
        n = max(n, 0)
        ans += 1.0/(2**n)/N
    print(ans)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


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

int N, M, Q; 
vector<vector<int>> sum;

int buildSumTable(vector<int> L, vector<int> R){
    sum = vector<vector<int>>(N + 1, vector<int>(N + 1, 0));
    for(int i=0; i<M; i++) sum[L[i]][R[i]]++;

    for(int i=1; i<=N; i++){
        for(int j=1; j<=N; j++){
            sum[i][j] += sum[i-1][j];
            sum[i][j] += sum[i][j-1];
            sum[i][j] -= sum[i-1][j-1];
        }
    }
}

int getSumRange(int L, int R){
    int ans = sum[R][R] - sum[R][L-1] - sum[L-1][R] + sum[L-1][L-1];
    return ans;
}

int main() {
    cin >> N >> M >> Q;
    vector<int> L(M), R(M);
    for(int i=0; i<M; i++) scanf("%d %d", &L[i], &R[i]); //cin >> L[i] >> R[i];
    vector<int> p(Q), q(Q);
    for(int i=0; i<Q; i++) scanf("%d %d", &p[i], &q[i]); //cin >> p[i] >> q[i];

    buildSumTable(L, R);

    for(int i=0; i<Q; i++){
        int ans = getSumRange(p[i], q[i]);
        cout << ans << endl;
    }
}


Measured memory_bytes: 5120
s = gets.chomp
n = s.length

ans = 0
(1 << (n - 1)).times.each do |x|
  mask = x.to_s(2).rjust(n, "0")
  expr = []
  n.times do |i|
    if mask[i] == "0" then
      expr += [s[i]]
    else
      expr += ["+", s[i]]
    end
  end
  ans += eval(expr.join)
end
puts ans


Measured memory_bytes: 1916
// https://atcoder.jp/contests/agc002/tasks/agc002_a
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, cnt = 0;
    cin >> a >> b;
    if (a <= 0 && b >= 0) {
        cout << "Zero\n";
    } else {
        if (b < 0) {
            cnt = b - a + 1;
        } else if (a < 0) {
            cnt = -a + 1;
        }
        if (cnt % 2 == 0) {
            cout << "Positive\n";
        } else {
            cout << "Negative\n";
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<(int)n;i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
//ONLINE_JUDGE   LOCAL
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}
 
int main(){
	//in_o();
 	int a,b;
 	string s;
 	cin>>a>>b>>s;
 	int n=s.length();
 	if(s[a]!='-')
 		return	cout<<"No",0;
 	FOR(i,0,n){
 		if(i!=a && !('0'<=s[i] && s[i]<='9')){
 			return	cout<<"No",0;
 		}
 	}
	return	cout<<"Yes",0;
}


Measured memory_bytes: 256
#include <iostream>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
 
using namespace std;

ll a[3];
 
int main() {
  fast_io;

  cin >> a[1] >> a[2] >> a[0];

  for (int i = 0; i < 3; i++) {
    cout << a[i] << " "; 
  }
 
  return 0;
}

Measured memory_bytes: 256