akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int N;
    cin >> N;
    
    // calculation
    int four_max = N/4, seven_max = N/7, count = 0;
    
    REP(i, four_max + 1) {
        REP(j, seven_max + 1) {
            if ((4*i + 7*j) == N) {
                cout << "Yes" << "\n";
                return 0;
            }
        }
    }
    
    cout << "No" << "\n";
    return 0;
}


Measured memory_bytes: 256
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

ll n,i,j;cin>>n;
vector<ll> a(n);
unordered_map<ll,ll> h;
for(i=0;i<n;i++) {cin>>a[i];h[a[i]]++;}
ll s=0;
for(auto x:h)
{
	s+=(x.second*(x.second-1))/2;
}
for(auto x: a)
{
	ll ans=s-(h[x]*(h[x]-1))/2+((h[x]-1)*(h[x]-2))/2;
	cout<<ans<<endl;
}

return 0;
}

Measured memory_bytes: 9160
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    long[long] cnt;
    foreach (a; A)
    {
        cnt[a] = cnt.get(a, 0) + 1;
    }
    if (!A.all!(a => a < N))
    {
        writeln("No");
        return;
    }
    switch (cnt.keys.length)
    {
    case 1:
        writeln((A[0] * 2 <= N || N - 1 == A[0]) ? "Yes" : "No");
        return;
    case 2:
        long a = cnt.keys[0];
        long b = cnt.keys[1];
        if (b < a)
            swap(a, b);
        if (b - a != 1)
        {
            writeln("No");
            return;
        }
        dprint(N - cnt[a], b - cnt[a]);
        writeln(cnt[a] < b && 2 * (b - cnt[a]) <= cnt[b] ? "Yes" : "No");
        return;
    default:
        writeln("No");
        return;
    }
}


Measured memory_bytes: 9072
//													\[T]/ Praise
//													 (*)  The
//													 / \  Sun



#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double dbl;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<long long> vl;
typedef vector< pair<int, int> > vii;
#define mp make_pair
#define pb push_back
#define invec(a, n) for(ll i = 0; i < n; i++) {cin >> a[i];}
#define rep(n) for(ll i = 0; i < n; i++)
#define fr(i,j,k) for(ll i = j; i < k; i++)
#define FR(i,j,k) for(ll i = j; i >= 0; i--)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define INF 1000000
#define xx first
#define yy second

void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

vector< vector<int> > adj;
vi vis, dp;

void dfs(int u)
{
	vis[u] = 1;

	for(auto v: adj[u])
	{
		if(!vis[v])
			dfs(v);

		dp[u] = max(dp[u], 1 + dp[v]);
	}
}


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

	adj.resize(n+1);
	vis.resize(n+1, 0);
	dp.resize(n+1, 0);

	fr(i,0,m)
	{
		int x, y;
		cin >> x >> y;
		adj[x].pb(y);
	}

	fr(i,0,n)
	{
		if(!vis[i+1])
			dfs(i+1);
	}
	

	cout << *max_element(all(dp));
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;

int N;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N;
  vector<int> v1(N+1, 0), v2(N+1, 0);
  for(int i=1; i<=N; ++i){
    int x; cin >> x;
    v1[i] = v1[i-1] + x;
  }
  vector<int> temp(N+1);
  for(int i=1; i<=N; ++i){
    cin >> temp[i];
  }
  for(int i=1; i<=N; ++i)
    v2[i] = temp[N-i+1] + v2[i-1];
  int res = 0;
  for(int i=1; i<=N; ++i){
     res = max(res, v1[i] + v2[N-i+1]);
  }
  cout << res << "\n";
  return 0; 
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <vector>
#define endl '\n';
using namespace std;

int main()
{   
    int w, a, b; cin >> w >> a >> b;
    int aw = a + w, bw = b + w;
    if (aw >= b && bw >= a) cout << 0;
    else if (b > aw) cout << b - aw;
    else cout << a - bw;
    return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
int main(void){
	ll i,j,k;
	ll n,m,s,g,b,e,pp,kou;
	ll ri[21][21];
	ll leng[21],v[21];
	ll min;
	
	PP p[100];
	
	cin>>n>>m;
	for(i=0;i<m;i++) scanf("%lld,%lld,%lld,%lld",&p[i].ff,&p[i].fs,&p[i].sf,&p[i].ss);
	scanf("%lld,%lld,%lld,%lld",&s,&g,&b,&e);
	
	//隣接行列
	sort(p,p+m);
	for(i=0;i<=n;i++) for(j=0;j<=n;j++) ri[i][j]=M;
	for(i=0;i<m;i++) ri[p[i].ff][p[i].fs]=p[i].sf,ri[p[i].fs][p[i].ff]=p[i].ss;
	
	//初期化
	for(k=0;k<=n;k++)leng[k]=M,v[k]=0;
	leng[s]=0;
	
	kou=0;
	//ダイクストラ法
	for(j=1;j<=n;j++){
		min=M;
		for(k=1;k<=n;k++) if(v[k]==0&&leng[k]<min) pp=k,min=leng[k];
		v[pp]=1;
		
		if(min==M)break;
		
		for(k=1;k<=n;k++){
			if((leng[pp]+ri[pp][k])<leng[k]) leng[k]=leng[pp]+ri[pp][k];
		}
	}
	kou+=leng[g];
//	cout<<leng[g]<<endl;
	
	//初期化
	for(k=0;k<=n;k++)leng[k]=M,v[k]=0;
	leng[g]=0;
	
	//ダイクストラ法
	for(j=1;j<=n;j++){
		min=M;
		for(k=1;k<=n;k++) if(v[k]==0&&leng[k]<min) pp=k,min=leng[k];
		v[pp]=1;
		
		if(min==M)break;
		
		for(k=1;k<=n;k++){
			if((leng[pp]+ri[pp][k])<leng[k]) leng[k]=leng[pp]+ri[pp][k];
		}
	}
	kou+=leng[s];
//	cout<<leng[s]<<endl;
	
	cout<<b-e-kou<<endl;
	return 0;
}


Measured memory_bytes: 3164
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % M;
}

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

	if (s.size() % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}

	rep(i,s.size() / 2) {
		if (s[2 * i] != 'h' || s[2 * i + 1] != 'i') {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}

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

int main(){
  int r, g, b;
  cin >> r >> g >> b;
  if((100 * r + 10 * g + b) % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3588
#include<iostream>
main(){for(int W,H,x,y,d,k,a[4]={0,1,0,-1};x=y=d=1,std::cin>>W>>H,W;printf("%d %d\n",x,y))for(char c[9];std::cin>>c,*c-83;d=(d+(*c==82)-(*c==76)+4)%4,x=x>W?W:x<1?1:x,y=y>H?H:y<1?1:y)if(*c==70|*c==66){std::cin>>k;x+=a[(d+3)%4]*k*(*c-68)/2;y+=a[d]*k*(*c-68)/2;}}

Measured memory_bytes: 0
// from alphaGem
#include<bits/stdc++.h>
using namespace std;
inline int gcd(register int a,register int b)
{
	register int t;
	for(;b;)t=a,a=b,b=t%b;
	return a;
}
int e[2333][2333],tr[2333][2333];
int a[2333],d[2333];
bool viz[2333];
int n;
void DFS(int u){viz[u]=1;for(int v=1;v<=n;v++)if(!viz[v]&&e[u][v])tr[u][v]=1,DFS(v);}
priority_queue<int>p;
void solve()
{
	memset(viz,0,sizeof(viz));
	for(p.push(0);!p.empty();)
	{
		int u=p.top();
		viz[u]=1;
		if(u)printf("%d ",a[u]);
		p.pop();
		for(int i=1;i<=n;i++)if(tr[u][i]&&!viz[i])p.push(i);
	}
}
int main()
{
	for(int i=scanf("%d",&n);i<=n;i++)scanf("%d",&a[i]);
	sort(&a[1],&a[n+1]);
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)if(gcd(a[i],a[j])>1)e[i][j]=e[j][i]=1;
	for(int i=1;i<=n;i++)if(!viz[i])tr[0][i]=1,DFS(i);
	solve();
	return 0;
}

Measured memory_bytes: 38144
#include "bits/stdc++.h"
using namespace std;

int main() {
    long long n;
    cin >> n;
    long long res = 2 * (n / 11);
    long long r = n % 11;
    if(r > 6) res += 2;
    else if(r > 0) res++;
    cout << res << endl;

}

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

int memo[3010][3010];
int N, T, S, A[3010], B[3010];

int rec(int n, int t){
	if(n >= N)
		return 0;
	if(t > T)
		return 0;
	if(memo[n][t] != -1)
		return memo[n][t];
	
	int res = 0;
	if(!(t < S && S < t + B[n]) && t + B[n] <= T){
		res = rec(n + 1, t + B[n]) + A[n];
	}
	res = max(res, rec(n, t + 1));
	res = max(res, rec(n + 1, t));
	return memo[n][t] = res;
}

int main() {
	memset(memo, -1, sizeof(memo));
	cin >> N >> T >> S;
	for(int i = 0; i < N; ++i)
		scanf("%d %d", &A[i], &B[i]);
		
	cout << rec(0, 0) << endl;
	return 0;
}

Measured memory_bytes: 37032
#pragma GCC optimize("O3")
#include<cstdio>
#include<map>
using namespace std;
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main() {
	int a[N];
	int b[N];
	int n, m, k;
	int x, y;
	int m1, m2, mm;
	int ans;
	while(true) {
		scanf("%d %d", &n, &m);
		if ((n == 0) && (m == 0))break;
		f(i, n) {
			a[i] = 0;
			b[i] = 0;
		}
		f(i, m) {
			scanf("%d", &x);
			scanf("%d", &k);
			f(j, k) {
				scanf("%d", &y);
				y--;
				if (k == 1)a[y] += x;
				b[y] += x;
			}
		}
		m1 = 1000000000;
		m2 = 1000000000;
		f(i, n) {
			if (a[i] < m1) {
				m1 = a[i];
				mm = i;
			}
			else if (a[i] < m2) {
				m2 = a[i];
			}
		}
		ans = 0;
		f(i, n) {
			x = b[i] - m1 + 1;
			if (mm == i)x = b[i] - m2 + 1;
			if (ans < x)ans = x;
		}
		printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 2772
N = int(input())
S = list(input())

r = g = b = 0
for i in range(N):
    if S[i] == 'R':
        r += 1
    if S[i] == 'G':
        g += 1
    if S[i] == 'B':
        b += 1
ans = r * g * b

for i in range(N):
    for j in range(i+1, N):
        dif = 2*j - i
        if dif >= N:
            break
        if S[i] != S[j] and S[i] != S[dif] and S[j] != S[dif]:
            ans -= 1
print(ans)

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9

int main() {
    int A,B;
    cin >> A >> B;
    cout << A*B << endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

int main(){
  ll i,j;
  ll n,k;
  cin>>n>>k;
  cout<<n-k+1<<endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;
int main()
{
    int n;
    cin >> n;
    map<string, bool> mp;
    rep(i, n)
    {
        string s;
        cin >> s;
        mp[s] = true;
    }
    cout << mp.size() << endl;
    return 0;
}

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



int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, K, S, T; cin >> N >> K >> S >> T;
    vector<int> bit;
    bool ok = true;
    for (int i = 0; i < 18; i++) {
        bool s = S & (1 << i);
        bool t = T & (1 << i);
        if (s && !t) ok = false;
        if (!s && t) bit.emplace_back(i);
    }

    if (!ok) {
        cout << 0 << "\n";
        return 0;
    }

    const int B = bit.size();
    vector<int> X;
    for (int i = 0; i < N; i++) {
        int A, C = 0; cin >> A;
        if ((A & S) == S && (A | T) == T) {
            for (int i = 0; i < B; i++) {
                if (A & (1 << bit[i])) C |= 1 << i; 
            }
            X.emplace_back(C);
        }
    }
    
    long long Bicom[51][51];
    memset(Bicom, 0, sizeof(Bicom));
    Bicom[0][0] = 1;
    for (int n = 0; n < 50; n++) {
        for (int r = 0; r <= n; r++) {
            Bicom[n+1][r] += Bicom[n][r];
            Bicom[n+1][r+1] += Bicom[n][r];
        }
    }

    const int M = X.size();
    const int mask = (1 << B) - 1;
    long long Ans = 0;
    for (int k = 1; k <= K; k++) Ans += Bicom[M][k];
    
    for (int first = 0; first < M; first++) {
        vector<long long> C(1 << B, 0);
        for (int i = first+1; i < M; i++) {
            int same = (X[first] ^ X[i]) ^ mask;
            C[same]++;
        }
        
        for (int i = B-1; i >= 0; i--) {
            for (int j = 0; j < (1 << B); j++) {
                if ((1<<i) & j) C[j^(1<<i)] += C[j];
            }
        }

        for (int i = 0; i < (1 << B); i++) {
            int x = C[i]; C[i] = 0;
            for (int k = 1; k < K; k++) {
                C[i] += Bicom[x][k];
            }
        }

        for (int i = B-1; i >= 0; i--) {
            for (int j = 0; j < (1 << B); j++) {
                if ((1<<i) & j) C[j^(1<<i)] -= C[j];
            }
        }
        
        for (int i = 1; i < (1 << B); i++) Ans -= C[i];
        Ans--;
    }

    cout << Ans << "\n";

    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define int long long
#define endl "\n"

int32_t main()
{
    IOS;
    
    int a,b;
    cin>>a>>b;
    
    int ans=a/b;
    if(a%b!=0)
        ans++;
    cout<<ans;    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main(){
string s;
cin>>s;
for(int i=0;i<s.size();i++){
    if(s.at(i)==','){
        s.at(i)=' ';
    }
}
cout<<s<<endl;
}










Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  while(n)
  {
    if(n%10==7)
    {cout<<"Yes";
     break;
    }
    n=n/10;
    if(n==0)
      cout<<"No";
  }
}

Measured memory_bytes: 3608
import collections
n=int(input())
l=[]
for _ in range(n):
  s=str(input())
  l.append(s)
g=collections.Counter(l)
h=sorted(g.items(),key=lambda x:x[1])
i=max(g.values())
j=[x for x,y in g.items() if y==i]
j=sorted(j)
for x in j:
  print(x)

Measured memory_bytes: 49280
#include <stdio.h>
#include <math.h>

void swap(int *,int *);
int search(int,int,int);
int correct[201][3];

int main(void)
{
	int a,b,c;
	int i,n;
	scanf("%d",&n);
	for(i=1;i<=200;i++){
		correct[i][0]=3*i;
		correct[i][1]=4*i;
		correct[i][2]=5*i;
	}
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a,&b,&c);
		if(b<a)swap(&a,&b);
		if(c<b)swap(&b,&c);
		if(b<a)swap(&a,&b);
		if( search(a,b,c) ) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

void swap(int *a,int *b){
	int work;
	work=*a;
	*a=*b;
	*b=work;
}

int search(int a,int b,int c){
	int i;
	for(i=1;i<201;i++){
		if( (correct[i][0]==a) && (correct[i][1]==b) && (correct[i][2]==c) ) return 1;
	}
	return 0;
}

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

int main() 
{
  int N;
  cin >> N;
  vector<int> h(N);
  for (int i = 0; i < N; i++) cin >> h.at(i);
  
  vector<int> dp(N, 0);
  dp.at(1) = abs(h.at(1) - h.at(0));
  
  for (int i = 2; i < N; i++)
  {
    int dif0 = abs(h.at(i) - h.at(i - 1));
    int dif1 = abs(h.at(i) - h.at(i - 2));
    dp.at(i) = min(dp.at(i - 1) + dif0, dp.at(i - 2) + dif1);
    //cout << dp.at(i) << endl;
  }
  
  int ans = dp.at(N - 1);
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long int ll;
typedef vector<ll> vec;

int main(int argc, char const *argv[])
{
    ll a,b,c;
    cin >> a>>b>>c;
   

    cout << a*b/2 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created by macbookpro on 2017/07/13.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            String inputString = sc.nextLine();
            String[] input= inputString.split(" ");
            int n = Integer.parseInt(input[0]);
            if(n==0){
                break;
            }
            int r=Integer.parseInt(input[1]);
            int[] card=new int[n];

            for(int i=0; i<n; i++){
                card[i]=n-i;
            }

            for(int i=0; i<r; i++) {
                String pcString = sc.nextLine();
                String[] pc = pcString.split(" ");
                int p = Integer.parseInt(pc[0]);
                int c = Integer.parseInt(pc[1]);
                int[] keep = new int[p-1];

                for (int j = 0; j < p - 1; j++) {
                    keep[j] = card[j];
                }

                for (int j = 0; j < c; j++) {
                    card[j] = card[p - 1 + j];
                }
                for(int j=0; j<p-1; j++){
                    card[j+c]=keep[j];
                }

            }
            System.out.println(card[0]);
        }
    }
}

Measured memory_bytes: 40456
def find_lcm(num1, num2):
    if(num1>num2):
        num = num1
        den = num2
    else:
        num = num2
        den = num1
    rem = num % den
    while(rem != 0):
        num = den
        den = rem
        rem = num % den
    gcd = den
    lcm = int(int(num1 * num2)/int(gcd))
    return lcm
n=  int(raw_input())
arr = map(int, raw_input().split())
lc = find_lcm(arr[0], arr[1])
for i in range(2, n):
    lc = find_lcm(lc, arr[i])
lc -= 1
ans = 0
for i in xrange(n):
    ans += (lc % arr[i])
print ans


Measured memory_bytes: 2872
import sys


def bfs(p_node, p_color):
    global K
    children_node = graph[p_node]
    c_color = 1
    for child_node in children_node:
        if c_color == p_color:
            c_color += 1
        colors[child_node] = c_color
        bfs(child_node, c_color)
        c_color += 1
    K = max(K, c_color - 1)


sys.setrecursionlimit(10**9)

N = int(input())
ab = []
graph = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    ab.append((a, b))
    graph[a].append(b)

colors = [-1] * (N + 1)
K = 0

bfs(1, -1)

print(K)
for a, b in ab:
    print(colors[b])


Measured memory_bytes: 69628
#include <stdio.h>
int main(){
    int m,now,temp,tot;
    char a[1001],b[1001];
    for(int i=0;i<1001;i++)b[i]=a[i]='\0';
    while(1){
        scanf("%s",a);
        if(a[0]=='-')return 0;
        now=0;
        while(a[now]!='\0')now++;
        scanf("%d",&m);
        tot=0;
        for(int i=0;i<m;i++){
            scanf("%d",&temp);
            tot+=temp;
        }
        temp=tot%now;
        for(int j=0;j<temp;j++)
            b[j]=a[j];
        for(int j=temp;j<now;j++){
            a[j-temp]=a[j];
        }
        for(int j=0;j<temp;j++){
            a[now-temp+j]=b[j];
        }
        
        for(int i=0;i<now;i++){
            printf("%c",a[i]);
            b[i]=a[i]='\0';
        }
        printf("\n");
    }
}

Measured memory_bytes: 2680
import sys
l = []
for line in sys.stdin:
    l.append(line)

for i in range(len(l)):
    numl = l[i].split(' ')
    a = int(numl[0])
    b = int(numl[1])
    sum = a + b
    digitstr = "{0}".format(sum)
    print(len(digitstr))

Measured memory_bytes: 7668
#include<bits/stdc++.h>
#define fr(i1,m) for(int i1=0;i1<m;i1++)
using namespace std;
int main()
{
     string s;
     while(cin>>s)
     {
         long l;
        if(s[0]=='a'||s[0]=='e'||s[0]=='i'||s[0]=='o'||s[0]=='u')
        {
            cout<<"vowel\n";
        }
        else
            cout<<"consonant\n";
     }
        return 0;

}




Measured memory_bytes: 256
from collections import Counter
N = int(input())
a = list(map(int,input().split()))
if sum(a) == 0:
    print('Yes')
else:
    if len(a)%3 != 0:
        print('No')
    else:
        counter = Counter(a)
        keys = list(counter.keys())
        vlen = len(set(counter.values()))
        if len(keys) >= 4 or len(keys) == 1:
            print('No')
        else:
            if len(keys) == 2:
                if 0 in counter:
                    if counter[0] == N//3:
                        print('Yes')
                    else:
                        print('No')
                else:
                    print('No')
            else:
                if (vlen == 1) and (keys[0]^keys[1]==keys[2]):
                    print('Yes')
                else:
                    print('No')

Measured memory_bytes: 14468
#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>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>

using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}

	return gcd(b, a % b);
}
int main() {
	ll A, B, C, D;
	cin >> A >> B >> C >> D;
	ll lcm = C * D / gcd(C, D);
	ll C_or_D_can = (B / C - (A - 1) / C) + (B / D - (A - 1) / D) - (B / lcm - (A - 1) / lcm);

	cout << (B - A + 1) - C_or_D_can;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int N;
    cin >> N;
    vector<long long> A(N), B(N);
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> B[i];
    priority_queue<pair<long long, int>> pq;
    for(int i=0; i<N; i++)
        if(B[i]!=A[i])
            pq.emplace(B[i], i);

    pair<long long, int> prv = make_pair(-1, -1);
    long long ans = 0;
    while(!pq.empty()){
        auto z = pq.top(); pq.pop();
        if(z==prv) break;;
        prv = z;
        long long b = z.first;
        int i = z.second;
        long long a = B[(i+N-1)%N];
        long long c = B[(i+1)%N];
        int n = (b-max(A[i], a+c+1))/(a+c);
        ans += n;
        b -= (a+c)*n;
        B[i] = b;

        if(b==A[i]) continue;
        ans++;
        b -= (a+c);
        B[i] = b;
        if(b==A[i]) continue;
        pq.emplace(B[i], i);
    }
    if(!pq.empty()) cout << -1 << endl;
    else cout << ans << endl;


    return 0;
}

Measured memory_bytes: 9072
s = list(input())
s_ever = []
s_odd = []
for i in range(len(s)):
  if i % 2 != 0:
    s_ever.append(s[i])
  else:
    s_odd.append(s[i])
if "L" not in s_odd and "R" not in s_ever:
  print("Yes")
else:
  print("No")

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

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

const long long MOD = 1000000007;

int main(){
  int n;
  string s;
  cin >> n >> s;
  set<int> r,g,b;
  rep(i,n){
    if(s.at(i)=='R') r.insert(i);
    if(s.at(i)=='G') g.insert(i);
    if(s.at(i)=='B') b.insert(i);
  }
  int y1,y2,y3;
  ll ans=0;
  for(int xr:r){
    for(int xg:g){
      int x=min(xr,xg),y=max(xr,xg);
      int d=y-x;
      ans+=b.size();
      if(b.count(x-d)) ans--;
      if(b.count(y+d)) ans--;
      if(d%2==0 && b.count(x+d/2)) ans--;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3800
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main(){
  char s[10];
  scanf("%s",s);
  int n;
  int flag = 0;
  for(n=0;n<strlen(s)-1;n++){
    if(s[n]=='A' && s[n+1]=='C'){
      flag = 1;
    }
  }
  if(flag==1){
  printf("Yes");}
  else{
    printf("No");
  }

}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;
// auto mod int
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {if ((x += a.x) >= mod) x -= mod; return *this;}
  mint& operator-=(const mint a) {if ((x += mod-a.x) >= mod) x -= mod; return *this;}
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  ll n,m;
  cin >> n >> m;
  vector<ll> x(n),y(m);
  rep(i,n) cin >> x[i];
  rep(i,m) cin >> y[i];
  mint h,w;
  rep(i,n-1) w += mint(x[i+1]-x[i])*(i+1)*(n-1-i);
  rep(i,m-1) h += mint(y[i+1]-y[i])*(i+1)*(m-1-i);
  cout << w*h << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;

vector<int>vis;
vector<vector<int>>adj;
void dfs(int u){
    if(vis[u])return;
    vis[u]=1;
    for(int v:adj[u])dfs(v);
}

int main() {
    int n,m;
    cin>>n>>m;
    vis.resize(n+3);
    adj.resize(n+3);
    for(int i=0;i<m;++i){
        int u,v,z;
        cin>>u>>v>>z;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int ans=0;
    for(int i=1;i<=n;++i){
        if(vis[i])continue;
        dfs(i);
        ++ans;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
  	int n,k,x;
  	cin>>n>>k;
  	int total=0;
  	for(int i=0 ; i<n ; ++i)
    {
    	cin>>x;
      	total+=min(2*x,2*abs(x-k));
    }
  	cout<<total<<endl;
	return 0;
}

Measured memory_bytes: 256
<?php

    // 末尾に改行をつけて出力
    function output($str) {
        echo $str . PHP_EOL;
    }

    $s = trim(fgets(STDIN));

    if ($s == 'AAA' || $s == 'BBB') {
        output('No');
    } else {
        output('Yes');
    }


Measured memory_bytes: 4728
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
 
using namespace std;
int main(){
    int n;std::cin >> n;
    int l[n];int ma,sum;
    ma=0;sum=0;
    rep(i,n){
        std::cin >> l[i];
        ma=max(ma,l[i]);
        sum+=l[i];
    }
    //std::cout << max<<" "<<sum << std::endl;
    if(ma<sum-ma)std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
}


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

int main(){
  string S;
  
  cin >> S ;
  sort(S.begin(), S.end());
  
  if(S.at(0)==S.at(1) and S.at(2)==S.at(3) and S.at(0)!=S.at(2)){
      cout << "Yes" << endl;
  }
  else{
      cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <iostream>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;


namespace libcomp {
namespace math {

vector<double> linear_equation_lu(
	vector< vector<double> > a, vector<double> b)
{
	const int n = b.size();
	for(int i = 0; i < n; ++i){
		int max_row = i;
		for(int j = i + 1; j < n; ++j){
			if(a[j][i] > a[max_row][i]){ max_row = j; }
		}
		if(max_row != i){
			a[i].swap(a[max_row]);
			swap(b[i], b[max_row]);
		}
		const double r = 1.0 / a[i][i];
		for(int j = i; j < n; ++j){ a[i][j] *= r; }
		b[i] *= r;
		for(int j = i + 1; j < n; ++j){
			if(a[j][i] == 0.0){ continue; }
			const double q = a[j][i];
			for(int k = i; k < n; ++k){ a[j][k] -= a[i][k] * q; }
			b[j] -= b[i] * q;
		}
	}
	for(int i = n - 2; i >= 0; --i){
		for(int j = i + 1; j < n; ++j){
			if(a[j][j] == 0.0){ return vector<double>(); }
			const double r = a[i][j] / a[j][j];
			a[i][j] -= a[j][j] * r;
			b[i] -= b[j] * r;
		}
	}
	return b;
}

}
}

const double EPS = 1e-2;

bool tolerant_eq(const vector<double> &a, const vector<double> &b){
	const int n = a.size();
	for(int i = 0; i < n; ++i){
		if(abs(a[i] - b[i]) > EPS){ return false; }
	}
	return true;
}

int main(){
	ios_base::sync_with_stdio(false);
	while(true){
		int d;
		cin >> d;
		if(d == 0){ break; }
		++d;
		const int e = d + 2;
		vector<double> v(e);
		for(int i = 0; i < e; ++i){ cin >> v[i]; }
		vector< vector<double> > solutions(1 << e);
		vector<int> written;
		for(int i = 0; i < (1 << e); ++i){
			if(__builtin_popcount(i) != d){ continue; }
			vector< vector<double> > A(d, vector<double>(d));
			vector<double> b(d);
			for(int j = 0, k = 0; j < e; ++j){
				if((i & (1 << j)) == 0){ continue; }
				double p = 1.0, r = j;
				for(int l = 0; l < d; ++l){
					A[k][l] = p;
					p *= r;
				}
				b[k] = v[j];
				++k;
			}
			solutions[i] = libcomp::math::linear_equation_lu(A, b);
			written.push_back(i);
		}
		int answer = -1;
		for(int i = 0; answer < 0 && i < e; ++i){
			vector<double> reference;
			bool failed = false;
			for(int j = 0; j < written.size(); ++j){
				const int k = written[j];
				if((k & (1 << i)) != 0){ continue; }
				if(reference.empty()){
					reference = solutions[k];
				}else if(!tolerant_eq(reference, solutions[k])){
					failed = true;
					break;
				}
			}
			if(!failed){ answer = i; }
		}
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
// 1,000,000,000,000,001
int main(void)
{
  int k;
  int count = 0;
  int array = 7;

  scanf("%d", &k);
  if (!(k & 1))
  {
    printf("-1\n");
    return 0;
  }
  array = array % k;
  while (1)
  {
    count++;
    if (array == 0)
    {
      break;
    }
    if (count >= k)
    {
      printf("-1\n");
      return 0;
    }
    array = (array * 10 + 7) % k;
    //printf("%d \n", array);
  }
  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 1724
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	int N;

	cin >> N;

	bool ok = false;
	for(int i = 0; i * 4 <= 100; i++){
		for(int j = 0; i * 4 + j * 7 <=100; j++){
			if(N == i * 4 + j * 7 ) {
				ok = true;
				break;
			}
		}
	}

	if(ok){
		cout << "Yes" << endl;
	} else{
	 	cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstdlib>
#define MAX 2000001
#define VMAX 10000

void CountingSort(int *, int *, int);

int n;

int main(){
  int *A, *B;
  int i, max = 0;

  scanf("%d", &n);

  A = (int *)malloc(sizeof(int)*n+1);
  B = (int *)malloc(sizeof(int)*n+1);

  /* your code */
  for(i = 1; i < n+1; i++){
    scanf("%d", &A[i]);
    if(max < A[i]){
      max = A[i];
    }
    //printf("max:%d\n",max);
  }
  
  CountingSort(A, B, max);
  for(i = 1; i < n; i++){
    printf("%d ", B[i]);
  }
  printf("%d\n", B[n]);



  return 0;
}


void CountingSort(int *A, int *B, int k){
  int i, j;
  int C[VMAX+1];
 
  for(i = 0; i <= k; i++){
    C[i] = 0;
  }
  
  // Put the number of each A[i] into C[A[i]]
  for(j = 1; j <= n; j++){
    C[A[j]]++;
    //printf("C[%d]:%d\n", A[j], C[A[j]]);
  }
  //printf("\n");
  
  // C to C'
  for(i = 1; i <= k; i++){
    C[i] += C[i-1];
    //printf("C[%d]:%d\n", i, C[i]);
  }
  
  for(j = n; j > 0; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}


















Measured memory_bytes: 18256
(* O(1) *)
let is_acgt_char = function
| 'A' | 'C' | 'G' | 'T' -> true
| _ -> false

(* O(|s|) *)
let solve s =
  let s2 = String.init (String.length s) (fun i -> if is_acgt_char s.[i] then '1' else '0') in
  Str.split (Str.regexp "0") s2 |> List.map String.length |> List.fold_left max 0

let _ = read_line () |> solve |> string_of_int |> print_endline

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

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

    rep (op1, 2) rep (op2, 2) rep (op3, 2) {
        int ans = s[0] - '0';
        ans += (op1 ? 1 : -1) * (s[1] - '0');
        ans += (op2 ? 1 : -1) * (s[2] - '0');
        ans += (op3 ? 1 : -1) * (s[3] - '0');
        if (ans == 7) {
            cout << s[0]
                 << (op1 ? "+" : "-")
                 << s[1]
                 << (op2 ? "+" : "-")
                 << s[2]
                 << (op3 ? "+" : "-")
                 << s[3]
                 << "=7\n";
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

int main() {
	vector<int> A(3);
	rep(i,3)cin>>A[i];
	sort(all(A));
	string ans = "NO";
	if(A[0] == 5&&A[1] == 5&&A[2] == 7)ans ="YES";

	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
int N, L, a[200000];
int check(int x)
{
	int l = N, r = N;
	while (l > 1 && (a[l - 1] >= x) != (a[l] >= x))
		l--;
	while (r < L && (a[r + 1] >= x) != (a[r] >= x))
		r++;
	if (l == 1 && r == L)
		return (a[N] >= x) ^ (N - 1 & 1);
	if (l == 1)
		return a[r] >= x;
	if (r == L)
		return a[l] >= x;
	if ((a[l] >= x) == (a[r] >= x))
		return a[l] >= x;
	return a[N <= l + r >> 1 ? l : r] >= x;
}
int main()
{
	scanf("%d", &N);
	L = N + N - 1;
	for (int i = 1; i <= L; i++)
		scanf("%d", a + i);
	int l = 1, r = L;
	while (l < r)
	{
		int m = l + r + 1 >> 1;
		if (check(m))
			l = m;
		else
			r = m - 1;
	}
	printf("%d\n", l);
	return 0;
}


Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var n int
	var s string

	fmt.Scan(&n)
	fmt.Scan(&s)

	t := "ABC"
	var count int
	for i := 0; i < n-len(t)+1; i++ {
		if s[i:i+len(t)] == t {
			count++
		}
	}
	fmt.Println(count)
}

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

int main(){
    int n,a,b;
    int P[100];
    int num[3];
    int sum;

    cin>>n;
    cin>>a>>b;

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

    sort(P,P+n);


    for (int i=0; i<3;i++) num[i]=0;

    for(int i=0;i<n;i++){
        if(P[i]<=a){
            num[0]+=1;
        }
        else if(P[i]<=b){
            num[1]+=1;
        }
        else{
            num[2]+=1;
        }
    }

   
  
  sort(num,num+3);

  cout<<num[0]<<endl;

  

}


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

// http://www.prefield.com/algorithm/misc/dice.html
enum FACE { TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT };
class dice {
public:
	dice(int top,int front,int right,int left,int back,int bottom) {
		id[TOP] = top; id[FRONT] = front; id[RIGHT] = right;
		id[LEFT] = left; id[BACK] = back; id[BOTTOM] = bottom;
	}
	int& operator[] (FACE f) { return id[f]; }
	const int& operator[] (FACE f) const { return id[f]; }
	bool operator==(const dice &b) const {
		const dice &a = *this;
		return a[TOP] == b[TOP] && a[BOTTOM] == b[BOTTOM] &&
			a[FRONT] == b[FRONT] && a[BACK] == b[BACK] &&
			 a[LEFT] == b[LEFT] && a[RIGHT] == b[RIGHT];
	}
	void roll_north() { roll(TOP, FRONT, BOTTOM, BACK); }
	void roll_south() { roll(TOP, BACK, BOTTOM, FRONT); }
	void roll_east() { roll(TOP, LEFT, BOTTOM, RIGHT); }
	void roll_west() { roll(TOP, RIGHT, BOTTOM, LEFT); }
	void roll_right() { roll(FRONT, LEFT, BACK, RIGHT); }
	void roll_left() { roll(FRONT, RIGHT, BACK, LEFT); }
private:
	void roll(FACE a, FACE b, FACE c, FACE d){
		int tmp = id[a];
		id[a] = id[b]; id[b] = id[c];
		id[c] = id[d]; id[d] = tmp;
	}
	int id[6];
};

int main(){
	int d[6];
	for(int i=0;i<6;i++)cin>>d[i];
	dice di(d[0],d[1],d[2],d[3],d[4],d[5]);
	string line;
	cin>>line;
	for(int i=0;i<line.size();i++){
		if(line[i]=='N')di.roll_north();
		if(line[i]=='E')di.roll_east();
		if(line[i]=='W')di.roll_west();
		if(line[i]=='S')di.roll_south();
	}
	cout<<di[TOP]<<endl;
}

Measured memory_bytes: 1204
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] abcd = sc.next().toCharArray();
    int a = abcd[0] - '0';
    int b = abcd[1] - '0';
    int c = abcd[2] - '0';
    int d = abcd[3] - '0';
    String ans = "";
    if (a + b + c + d == 7) {
      ans = "" + a + "+" + b + "+" + c + "+" + d + "=7";
    }
    if (a - b + c + d == 7) {
      ans = "" + a + "-" + b + "+" + c + "+" + d + "=7";
    }
    if (a + b - c + d == 7) {
      ans = "" + a + "+" + b + "-" + c + "+" + d + "=7";
    }
    if (a + b + c - d == 7) {
      ans = "" + a + "+" + b + "+" + c + "-" + d + "=7";
    }
    if (a + b - c - d == 7) {
      ans = "" + a + "+" + b + "-" + c + "-" + d + "=7";
    }
    if (a - b + c - d == 7) {
      ans = "" + a + "-" + b + "+" + c + "-" + d + "=7";
    }
    if (a - b - c + d == 7) {
      ans = "" + a + "-" + b + "-" + c + "+" + d + "=7";
    }
    if (a - b - c - d == 7) {
      ans = "" + a + "-" + b + "-" + c + "-" + d + "=7";
    }
    System.out.println(ans);
  }
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define pb push_back
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;

const ll maxn = 1e5 + 10, MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}


void init() {

}

map<int,int> ma;

int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
//    ios_base::sync_with_stdio(0);
    init();
    ma[0] = 1;
    int n,m; cin >>n >> m;
    int now = 0;
    ll r = 0;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        now = (now + x) % m;
        r += 1ll * ma[now]++;
    }
    cout << r << endl;
    return 0;
}


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

int main() {
  //データの数Nセーブ用のSを宣言
  int N, S, A=0;
  
  //データの数を入力
  cin >> N;
  
  //一列の行列を宣言dataが読み込み用data_newが書き込み用
  vector<int> data(N);
  
  
  //データを読み込み
  for(int i = 0;i < N; i++){
    cin >> data.at(i);
  }
  
  
  //データを大きい順に並べる
  for(int i = 0;i < N-1 ; i++){
    for(int j = i+1 ; j < N; j++){
      if( data.at(i) < data.at(j) ){
        S = data.at(j);
        data.at(j) = data.at(i);
        data.at(i) = S;
      } 
    }
  }
  
  //奇数と偶数で場合分け
  if( N % 2 == 0){
    for(int i = 0; i < N  ; i += 2){
      A += data.at(i) - data.at (i + 1);
    }
  }
  else{
    int i ;
    for(i = 0; i < N - 1 ; i += 2){
      A += data.at(i) - data.at (i + 1);
    }
    A += data.at(i);
  }
  
  cout << A << endl;
}
  

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
char s[100010];
int main(){
  int n, m, k;
  while(cin>>n>>k){
    scanf("%s",s);
    int ans=0, cnt=0;
    for(int i=0; i+1<n; ++i){
        if(s[i]==s[i+1]){
            ++ans;
        }
    }
    vector <int> v;
    for(int i=0; i+1<n; ++i){
        if(s[i]!=s[i+1]){
            int j=i+1;
            for(j;j<n;++j){
                if(s[j]!=s[j+1]){
                    break;
                }
            }
            if(j!=n-1){
                v.push_back(2);
            }
            else{
                v.push_back(1);
            }
            i=j;
        }
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    for(int i=0; i<min(k, (int)v.size()); ++i){
        ans+=v[i];
    }
    cout<<ans<<endl;
  }
  return 0;
}




Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N=100000;
signed long long x,y,ans;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>x>>y;
	ans=0;
	while(x<y){
		ans++;
		x*=2;
	}
	if(x==y)ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256